summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-06-13 14:57:29 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-13 14:57:29 -0700
commit868150bd69f0f1f9472affc20deea0a9341bf22b (patch)
tree07ebd9327583ecc20ebb43b800c2f36501a80068 /core/fpdfapi
parent82e24b1c5047076b982c073671315071760b9880 (diff)
downloadpdfium-868150bd69f0f1f9472affc20deea0a9341bf22b.tar.xz
Make code compile with clang_use_chrome_plugin (part I)
This change contains files in core/fpdfapi directory. This is part of the efforts to make PDFium code compilable by Clang chromium style plugins. The changes are mainly the following: -- move inline constructor/destructor of complex class/struct out-of-line; -- add constructor/destructor of complex class/struct if not explicitly defined; -- add explicit out-of-line copy constructor when needed; -- move inline virtual functions out-of-line; -- Properly mark virtual functions with 'override'; -- some minor cleanups; BUG=pdfium:469 Review-Url: https://codereview.chromium.org/2060973002
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp2
-rw-r--r--core/fpdfapi/fpdf_edit/editint.h3
-rw-r--r--core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp6
-rw-r--r--core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h1
-rw-r--r--core/fpdfapi/fpdf_font/cpdf_simplefont.h5
-rw-r--r--core/fpdfapi/fpdf_font/font_int.h21
-rw-r--r--core/fpdfapi/fpdf_font/fpdf_font.cpp8
-rw-r--r--core/fpdfapi/fpdf_font/fpdf_font_cid.cpp19
-rw-r--r--core/fpdfapi/fpdf_font/ttgsubtable.cpp143
-rw-r--r--core/fpdfapi/fpdf_font/ttgsubtable.h182
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_allstates.h2
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_colorspace.cpp55
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_contentmarkdata.cpp12
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_contentmarkdata.h9
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_formobject.cpp16
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_graphicstates.cpp4
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_graphicstates.h3
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_imageobject.cpp16
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_pagemodule.cpp16
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_pagemodule.h14
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_pageobject.cpp60
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_pageobjectholder.cpp2
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_pathobject.cpp16
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp16
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp8
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_shadingpattern.h4
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_textobject.cpp70
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp8
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_tilingpattern.h4
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_colorspace.h37
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_form.h3
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_formobject.h8
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_imageobject.h10
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_page.h2
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_pageobject.h32
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h1
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_pathobject.h10
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_shadingobject.h10
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_textobject.h22
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp6
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_data_avail.h4
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp7
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_hint_tables.h6
-rw-r--r--core/fpdfapi/fpdf_render/cpdf_pagerendercache.h7
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_cache.cpp7
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_image.cpp5
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_text.cpp8
-rw-r--r--core/fpdfapi/fpdf_render/render_int.h10
48 files changed, 674 insertions, 246 deletions
diff --git a/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp
index 20ae34349b..7ddc211671 100644
--- a/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp
+++ b/core/fpdfapi/fpdf_edit/cpdf_pagecontentgenerator.cpp
@@ -31,6 +31,8 @@ CPDF_PageContentGenerator::CPDF_PageContentGenerator(CPDF_Page* pPage)
InsertPageObject(pObj.get());
}
+CPDF_PageContentGenerator::~CPDF_PageContentGenerator() {}
+
FX_BOOL CPDF_PageContentGenerator::InsertPageObject(
CPDF_PageObject* pPageObject) {
return pPageObject && m_pageObjects.Add(pPageObject);
diff --git a/core/fpdfapi/fpdf_edit/editint.h b/core/fpdfapi/fpdf_edit/editint.h
index a7774050ae..cd04d5de4f 100644
--- a/core/fpdfapi/fpdf_edit/editint.h
+++ b/core/fpdfapi/fpdf_edit/editint.h
@@ -24,6 +24,7 @@ class CPDF_ObjectStream {
};
CPDF_ObjectStream();
+ ~CPDF_ObjectStream();
void Start();
FX_FILESIZE End(CPDF_Creator* pCreator);
@@ -46,6 +47,7 @@ class CPDF_XRefStream {
};
CPDF_XRefStream();
+ ~CPDF_XRefStream();
FX_BOOL Start();
int32_t CompressIndirectObject(uint32_t dwObjNum,
@@ -66,6 +68,7 @@ class CPDF_XRefStream {
protected:
int32_t EndObjectStream(CPDF_Creator* pCreator, FX_BOOL bEOF = TRUE);
FX_BOOL GenerateXRefStream(CPDF_Creator* pCreator, FX_BOOL bEOF);
+
size_t m_iSeg;
CPDF_ObjectStream m_ObjStream;
CFX_ByteTextBuf m_Buffer;
diff --git a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index 09833d82cc..c20a483764 100644
--- a/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
+++ b/core/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
@@ -517,6 +517,8 @@ CPDF_Encryptor::~CPDF_Encryptor() {
CPDF_ObjectStream::CPDF_ObjectStream() : m_dwObjNum(0), m_index(0) {}
+CPDF_ObjectStream::~CPDF_ObjectStream() {}
+
void CPDF_ObjectStream::Start() {
m_Items.clear();
m_Buffer.Clear();
@@ -603,8 +605,12 @@ FX_FILESIZE CPDF_ObjectStream::End(CPDF_Creator* pCreator) {
offset += len;
return ObjOffset;
}
+
CPDF_XRefStream::CPDF_XRefStream()
: m_PrevOffset(0), m_dwTempObjNum(0), m_iSeg(0) {}
+
+CPDF_XRefStream::~CPDF_XRefStream() {}
+
FX_BOOL CPDF_XRefStream::Start() {
m_IndexArray.clear();
m_Buffer.Clear();
diff --git a/core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h b/core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h
index f60b083be1..adcac171a5 100644
--- a/core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h
+++ b/core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h
@@ -20,6 +20,7 @@ class CPDF_ImageObject;
class CPDF_PageContentGenerator {
public:
explicit CPDF_PageContentGenerator(CPDF_Page* pPage);
+ ~CPDF_PageContentGenerator();
FX_BOOL InsertPageObject(CPDF_PageObject* pPageObject);
void GenerateContent();
diff --git a/core/fpdfapi/fpdf_font/cpdf_simplefont.h b/core/fpdfapi/fpdf_font/cpdf_simplefont.h
index 881744a405..51266bbe6c 100644
--- a/core/fpdfapi/fpdf_font/cpdf_simplefont.h
+++ b/core/fpdfapi/fpdf_font/cpdf_simplefont.h
@@ -15,9 +15,9 @@
class CPDF_SimpleFont : public CPDF_Font {
public:
CPDF_SimpleFont();
- virtual ~CPDF_SimpleFont();
+ ~CPDF_SimpleFont() override;
- // CPDF_Font:
+ // CPDF_Font
int GetCharWidthF(uint32_t charcode, int level = 0) override;
FX_RECT GetCharBBox(uint32_t charcode, int level = 0) override;
int GlyphFromCharCode(uint32_t charcode,
@@ -33,7 +33,6 @@ class CPDF_SimpleFont : public CPDF_Font {
FX_BOOL LoadCommon();
void LoadSubstFont();
- void LoadFaceMetrics();
void LoadCharMetrics(int charcode);
CPDF_FontEncoding m_Encoding;
diff --git a/core/fpdfapi/fpdf_font/font_int.h b/core/fpdfapi/fpdf_font/font_int.h
index e159b1e34c..ea6c246e78 100644
--- a/core/fpdfapi/fpdf_font/font_int.h
+++ b/core/fpdfapi/fpdf_font/font_int.h
@@ -28,6 +28,7 @@ class CPDF_CMapManager {
public:
CPDF_CMapManager();
~CPDF_CMapManager();
+
void* GetPackage(FX_BOOL bPrompt);
CPDF_CMap* GetPredefinedCMap(const CFX_ByteString& name, FX_BOOL bPromptCJK);
CPDF_CID2UnicodeMap* GetCID2UnicodeMap(CIDSet charset, FX_BOOL bPromptCJK);
@@ -89,7 +90,7 @@ struct CMap_CodeRange {
class CPDF_CMapParser {
public:
CPDF_CMapParser();
- ~CPDF_CMapParser() {}
+ ~CPDF_CMapParser();
FX_BOOL Initialize(CPDF_CMap* pMap);
void ParseWord(const CFX_ByteStringC& str);
CFX_BinaryBuf m_AddMaps;
@@ -108,7 +109,9 @@ class CPDF_CMapParser {
int m_CodeSeq;
uint32_t m_CodePoints[4];
CFX_ArrayTemplate<CMap_CodeRange> m_CodeRanges;
- CFX_ByteString m_Registry, m_Ordering, m_Supplement;
+ CFX_ByteString m_Registry;
+ CFX_ByteString m_Ordering;
+ CFX_ByteString m_Supplement;
CFX_ByteString m_LastWord;
};
@@ -140,8 +143,9 @@ class CPDF_CMap {
FX_BOOL bPromptCJK);
FX_BOOL LoadEmbedded(const uint8_t* pData, uint32_t dwSize);
void Release();
- FX_BOOL IsLoaded() const { return m_bLoaded; }
- FX_BOOL IsVertWriting() const { return m_bVertical; }
+
+ FX_BOOL IsLoaded() const;
+ FX_BOOL IsVertWriting() const;
uint16_t CIDFromCharCode(uint32_t charcode) const;
uint32_t CharCodeFromCID(uint16_t CID) const;
int GetCharSize(uint32_t charcode) const;
@@ -172,6 +176,7 @@ class CPDF_CID2UnicodeMap {
public:
CPDF_CID2UnicodeMap();
~CPDF_CID2UnicodeMap();
+
FX_BOOL Initialize();
FX_BOOL IsLoaded();
void Load(CPDF_CMapManager* pMgr, CIDSet charset, FX_BOOL bPromptCJK);
@@ -185,9 +190,13 @@ class CPDF_CID2UnicodeMap {
class CPDF_ToUnicodeMap {
public:
+ CPDF_ToUnicodeMap();
+ ~CPDF_ToUnicodeMap();
+
void Load(CPDF_Stream* pStream);
- CFX_WideString Lookup(uint32_t charcode);
- uint32_t ReverseLookup(FX_WCHAR unicode);
+
+ CFX_WideString Lookup(uint32_t charcode) const;
+ uint32_t ReverseLookup(FX_WCHAR unicode) const;
protected:
std::map<uint32_t, uint32_t> m_Map;
diff --git a/core/fpdfapi/fpdf_font/fpdf_font.cpp b/core/fpdfapi/fpdf_font/fpdf_font.cpp
index e5442215c4..1735f0ba25 100644
--- a/core/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -93,7 +93,7 @@ short TT2PDF(int m, FXFT_Face face) {
return (m * 1000 + upm / 2) / upm;
}
-CFX_WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) {
+CFX_WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) const {
auto it = m_Map.find(charcode);
if (it != m_Map.end()) {
uint32_t value = it->second;
@@ -122,7 +122,7 @@ CFX_WideString CPDF_ToUnicodeMap::Lookup(uint32_t charcode) {
return CFX_WideString();
}
-uint32_t CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) {
+uint32_t CPDF_ToUnicodeMap::ReverseLookup(FX_WCHAR unicode) const {
for (const auto& pair : m_Map) {
if (pair.second == static_cast<uint32_t>(unicode))
return pair.first;
@@ -193,6 +193,10 @@ CFX_WideString CPDF_ToUnicodeMap::StringToWideString(
return result;
}
+CPDF_ToUnicodeMap::CPDF_ToUnicodeMap() : m_pBaseMap(nullptr) {}
+
+CPDF_ToUnicodeMap::~CPDF_ToUnicodeMap() {}
+
void CPDF_ToUnicodeMap::Load(CPDF_Stream* pStream) {
CIDSet cid_set = CIDSET_UNKNOWN;
CPDF_StreamAcc stream;
diff --git a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp
index 2a55955cc0..efc5e7cedc 100644
--- a/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/core/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -341,11 +341,12 @@ CPDF_CID2UnicodeMap* CPDF_CMapManager::LoadCID2UnicodeMap(CIDSet charset,
pMap->Load(this, charset, bPromptCJK);
return pMap;
}
-CPDF_CMapParser::CPDF_CMapParser() {
- m_pCMap = nullptr;
- m_Status = 0;
- m_CodeSeq = 0;
-}
+
+CPDF_CMapParser::CPDF_CMapParser()
+ : m_pCMap(nullptr), m_Status(0), m_CodeSeq(0) {}
+
+CPDF_CMapParser::~CPDF_CMapParser() {}
+
FX_BOOL CPDF_CMapParser::Initialize(CPDF_CMap* pCMap) {
m_pCMap = pCMap;
m_Status = 0;
@@ -525,6 +526,14 @@ void CPDF_CMap::Release() {
}
}
+FX_BOOL CPDF_CMap::IsLoaded() const {
+ return m_bLoaded;
+}
+
+FX_BOOL CPDF_CMap::IsVertWriting() const {
+ return m_bVertical;
+}
+
FX_BOOL CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr,
const FX_CHAR* pName,
FX_BOOL bPromptCJK) {
diff --git a/core/fpdfapi/fpdf_font/ttgsubtable.cpp b/core/fpdfapi/fpdf_font/ttgsubtable.cpp
index 5734816a87..8900e274fe 100644
--- a/core/fpdfapi/fpdf_font/ttgsubtable.cpp
+++ b/core/fpdfapi/fpdf_font/ttgsubtable.cpp
@@ -13,16 +13,20 @@
#include "third_party/base/stl_util.h"
CFX_GlyphMap::CFX_GlyphMap() {}
+
CFX_GlyphMap::~CFX_GlyphMap() {}
+
extern "C" {
static int _CompareInt(const void* p1, const void* p2) {
return (*(uint32_t*)p1) - (*(uint32_t*)p2);
}
};
+
struct _IntPair {
int32_t key;
int32_t value;
};
+
void CFX_GlyphMap::SetAt(int key, int value) {
uint32_t count = m_Buffer.GetSize() / sizeof(_IntPair);
_IntPair* buf = (_IntPair*)m_Buffer.GetBuffer();
@@ -45,6 +49,7 @@ void CFX_GlyphMap::SetAt(int key, int value) {
}
m_Buffer.InsertBlock(low * sizeof(_IntPair), &pair, sizeof(_IntPair));
}
+
FX_BOOL CFX_GlyphMap::Lookup(int key, int& value) {
void* pResult = FXSYS_bsearch(&key, m_Buffer.GetBuffer(),
m_Buffer.GetSize() / sizeof(_IntPair),
@@ -55,6 +60,21 @@ FX_BOOL CFX_GlyphMap::Lookup(int key, int& value) {
value = ((uint32_t*)pResult)[1];
return TRUE;
}
+
+CFX_CTTGSUBTable::CFX_CTTGSUBTable(void)
+ : m_bFeautureMapLoad(FALSE), loaded(false) {}
+
+CFX_CTTGSUBTable::CFX_CTTGSUBTable(FT_Bytes gsub)
+ : m_bFeautureMapLoad(FALSE), loaded(false) {
+ LoadGSUBTable(gsub);
+}
+
+CFX_CTTGSUBTable::~CFX_CTTGSUBTable() {}
+
+bool CFX_CTTGSUBTable::IsOk(void) const {
+ return loaded;
+}
+
bool CFX_CTTGSUBTable::LoadGSUBTable(FT_Bytes gsub) {
header.Version = gsub[0] << 24 | gsub[1] << 16 | gsub[2] << 8 | gsub[3];
if (header.Version != 0x00010000) {
@@ -66,6 +86,7 @@ bool CFX_CTTGSUBTable::LoadGSUBTable(FT_Bytes gsub) {
return Parse(&gsub[header.ScriptList], &gsub[header.FeatureList],
&gsub[header.LookupList]);
}
+
bool CFX_CTTGSUBTable::GetVerticalGlyph(uint32_t glyphnum,
uint32_t* vglyphnum) {
uint32_t tag[] = {
@@ -113,9 +134,10 @@ bool CFX_CTTGSUBTable::GetVerticalGlyph(uint32_t glyphnum,
}
return false;
}
+
bool CFX_CTTGSUBTable::GetVerticalGlyphSub(uint32_t glyphnum,
uint32_t* vglyphnum,
- struct TFeature* Feature) {
+ struct TFeature* Feature) const {
for (int i = 0; i < Feature->LookupCount; i++) {
int index = Feature->LookupListIndex[i];
if (index < 0 || LookupList.LookupCount < index) {
@@ -130,9 +152,10 @@ bool CFX_CTTGSUBTable::GetVerticalGlyphSub(uint32_t glyphnum,
}
return false;
}
+
bool CFX_CTTGSUBTable::GetVerticalGlyphSub2(uint32_t glyphnum,
uint32_t* vglyphnum,
- struct TLookup* Lookup) {
+ struct TLookup* Lookup) const {
for (int i = 0; i < Lookup->SubTableCount; i++) {
switch (Lookup->SubTable[i]->SubstFormat) {
case 1: {
@@ -157,8 +180,9 @@ bool CFX_CTTGSUBTable::GetVerticalGlyphSub2(uint32_t glyphnum,
}
return false;
}
+
int CFX_CTTGSUBTable::GetCoverageIndex(struct TCoverageFormatBase* Coverage,
- uint32_t g) {
+ uint32_t g) const {
int i = 0;
if (!Coverage) {
return -1;
@@ -188,6 +212,37 @@ int CFX_CTTGSUBTable::GetCoverageIndex(struct TCoverageFormatBase* Coverage,
}
return -1;
}
+
+uint8_t CFX_CTTGSUBTable::GetUInt8(FT_Bytes& p) const {
+ uint8_t ret = p[0];
+ p += 1;
+ return ret;
+}
+
+int16_t CFX_CTTGSUBTable::GetInt16(FT_Bytes& p) const {
+ uint16_t ret = p[0] << 8 | p[1];
+ p += 2;
+ return *(int16_t*)&ret;
+}
+
+uint16_t CFX_CTTGSUBTable::GetUInt16(FT_Bytes& p) const {
+ uint16_t ret = p[0] << 8 | p[1];
+ p += 2;
+ return ret;
+}
+
+int32_t CFX_CTTGSUBTable::GetInt32(FT_Bytes& p) const {
+ uint32_t ret = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
+ p += 4;
+ return *(int32_t*)&ret;
+}
+
+uint32_t CFX_CTTGSUBTable::GetUInt32(FT_Bytes& p) const {
+ uint32_t ret = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
+ p += 4;
+ return ret;
+}
+
bool CFX_CTTGSUBTable::Parse(FT_Bytes scriptlist,
FT_Bytes featurelist,
FT_Bytes lookuplist) {
@@ -196,6 +251,7 @@ bool CFX_CTTGSUBTable::Parse(FT_Bytes scriptlist,
ParseLookupList(lookuplist, &LookupList);
return true;
}
+
void CFX_CTTGSUBTable::ParseScriptList(FT_Bytes raw, struct TScriptList* rec) {
int i;
FT_Bytes sp = raw;
@@ -210,6 +266,7 @@ void CFX_CTTGSUBTable::ParseScriptList(FT_Bytes raw, struct TScriptList* rec) {
ParseScript(&raw[offset], &rec->ScriptRecord[i].Script);
}
}
+
void CFX_CTTGSUBTable::ParseScript(FT_Bytes raw, struct TScript* rec) {
int i;
FT_Bytes sp = raw;
@@ -225,6 +282,7 @@ void CFX_CTTGSUBTable::ParseScript(FT_Bytes raw, struct TScript* rec) {
ParseLangSys(&raw[offset], &rec->LangSysRecord[i].LangSys);
}
}
+
void CFX_CTTGSUBTable::ParseLangSys(FT_Bytes raw, struct TLangSys* rec) {
FT_Bytes sp = raw;
rec->LookupOrder = GetUInt16(sp);
@@ -239,6 +297,7 @@ void CFX_CTTGSUBTable::ParseLangSys(FT_Bytes raw, struct TLangSys* rec) {
rec->FeatureIndex[i] = GetUInt16(sp);
}
}
+
void CFX_CTTGSUBTable::ParseFeatureList(FT_Bytes raw, TFeatureList* rec) {
int i;
FT_Bytes sp = raw;
@@ -253,6 +312,7 @@ void CFX_CTTGSUBTable::ParseFeatureList(FT_Bytes raw, TFeatureList* rec) {
ParseFeature(&raw[offset], &rec->FeatureRecord[i].Feature);
}
}
+
void CFX_CTTGSUBTable::ParseFeature(FT_Bytes raw, TFeature* rec) {
int i;
FT_Bytes sp = raw;
@@ -266,6 +326,7 @@ void CFX_CTTGSUBTable::ParseFeature(FT_Bytes raw, TFeature* rec) {
rec->LookupListIndex[i] = GetUInt16(sp);
}
}
+
void CFX_CTTGSUBTable::ParseLookupList(FT_Bytes raw, TLookupList* rec) {
int i;
FT_Bytes sp = raw;
@@ -279,6 +340,7 @@ void CFX_CTTGSUBTable::ParseLookupList(FT_Bytes raw, TLookupList* rec) {
ParseLookup(&raw[offset], &rec->Lookup[i]);
}
}
+
void CFX_CTTGSUBTable::ParseLookup(FT_Bytes raw, TLookup* rec) {
int i;
FT_Bytes sp = raw;
@@ -300,6 +362,7 @@ void CFX_CTTGSUBTable::ParseLookup(FT_Bytes raw, TLookup* rec) {
ParseSingleSubst(&raw[offset], &rec->SubTable[i]);
}
}
+
void CFX_CTTGSUBTable::ParseCoverage(FT_Bytes raw, TCoverageFormatBase** rec) {
FT_Bytes sp = raw;
uint16_t Format = GetUInt16(sp);
@@ -314,6 +377,7 @@ void CFX_CTTGSUBTable::ParseCoverage(FT_Bytes raw, TCoverageFormatBase** rec) {
break;
}
}
+
void CFX_CTTGSUBTable::ParseCoverageFormat1(FT_Bytes raw,
TCoverageFormat1* rec) {
int i;
@@ -328,6 +392,7 @@ void CFX_CTTGSUBTable::ParseCoverageFormat1(FT_Bytes raw,
rec->GlyphArray[i] = GetUInt16(sp);
}
}
+
void CFX_CTTGSUBTable::ParseCoverageFormat2(FT_Bytes raw,
TCoverageFormat2* rec) {
int i;
@@ -344,6 +409,7 @@ void CFX_CTTGSUBTable::ParseCoverageFormat2(FT_Bytes raw,
rec->RangeRecord[i].StartCoverageIndex = GetUInt16(sp);
}
}
+
void CFX_CTTGSUBTable::ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec) {
FT_Bytes sp = raw;
uint16_t Format = GetUInt16(sp);
@@ -358,6 +424,7 @@ void CFX_CTTGSUBTable::ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec) {
break;
}
}
+
void CFX_CTTGSUBTable::ParseSingleSubstFormat1(FT_Bytes raw,
TSingleSubstFormat1* rec) {
FT_Bytes sp = raw;
@@ -366,6 +433,7 @@ void CFX_CTTGSUBTable::ParseSingleSubstFormat1(FT_Bytes raw,
ParseCoverage(&raw[offset], &rec->Coverage);
rec->DeltaGlyphID = GetInt16(sp);
}
+
void CFX_CTTGSUBTable::ParseSingleSubstFormat2(FT_Bytes raw,
TSingleSubstFormat2* rec) {
int i;
@@ -382,3 +450,72 @@ void CFX_CTTGSUBTable::ParseSingleSubstFormat2(FT_Bytes raw,
rec->Substitute[i] = GetUInt16(sp);
}
}
+
+CFX_CTTGSUBTable::TCoverageFormat1::TCoverageFormat1()
+ : GlyphCount(0), GlyphArray(nullptr) {
+ CoverageFormat = 1;
+}
+
+CFX_CTTGSUBTable::TCoverageFormat1::~TCoverageFormat1() {
+ delete[] GlyphArray;
+}
+
+CFX_CTTGSUBTable::TRangeRecord::TRangeRecord()
+ : Start(0), End(0), StartCoverageIndex(0) {}
+
+CFX_CTTGSUBTable::TCoverageFormat2::TCoverageFormat2()
+ : RangeCount(0), RangeRecord(nullptr) {
+ CoverageFormat = 2;
+}
+
+CFX_CTTGSUBTable::TCoverageFormat2::~TCoverageFormat2() {
+ delete[] RangeRecord;
+}
+
+CFX_CTTGSUBTable::TClassDefFormat1::TClassDefFormat1()
+ : StartGlyph(0), GlyphCount(0), ClassValueArray(nullptr) {
+ ClassFormat = 1;
+}
+
+CFX_CTTGSUBTable::TClassDefFormat1::~TClassDefFormat1() {
+ delete[] ClassValueArray;
+}
+
+CFX_CTTGSUBTable::TClassDefFormat2::TClassDefFormat2()
+ : ClassRangeCount(0), ClassRangeRecord(nullptr) {
+ ClassFormat = 2;
+}
+
+CFX_CTTGSUBTable::TClassDefFormat2::~TClassDefFormat2() {
+ delete[] ClassRangeRecord;
+}
+
+CFX_CTTGSUBTable::TSingleSubstFormat1::TSingleSubstFormat1()
+ : Coverage(nullptr), DeltaGlyphID(0) {
+ SubstFormat = 1;
+}
+
+CFX_CTTGSUBTable::TSingleSubstFormat1::~TSingleSubstFormat1() {
+ delete Coverage;
+}
+
+CFX_CTTGSUBTable::TSingleSubstFormat2::TSingleSubstFormat2()
+ : Coverage(nullptr), GlyphCount(0), Substitute(nullptr) {
+ SubstFormat = 2;
+}
+
+CFX_CTTGSUBTable::TSingleSubstFormat2::~TSingleSubstFormat2() {
+ delete Coverage;
+ delete[] Substitute;
+}
+
+CFX_CTTGSUBTable::TLookup::TLookup()
+ : LookupType(0), LookupFlag(0), SubTableCount(0), SubTable(nullptr) {}
+
+CFX_CTTGSUBTable::TLookup::~TLookup() {
+ if (SubTable) {
+ for (int i = 0; i < SubTableCount; ++i)
+ delete SubTable[i];
+ delete[] SubTable;
+ }
+}
diff --git a/core/fpdfapi/fpdf_font/ttgsubtable.h b/core/fpdfapi/fpdf_font/ttgsubtable.h
index 830e67af88..de7a4f03ec 100644
--- a/core/fpdfapi/fpdf_font/ttgsubtable.h
+++ b/core/fpdfapi/fpdf_font/ttgsubtable.h
@@ -19,6 +19,7 @@ class CFX_GlyphMap {
public:
CFX_GlyphMap();
~CFX_GlyphMap();
+
void SetAt(int key, int value);
FX_BOOL Lookup(int key, int& value);
@@ -28,12 +29,11 @@ class CFX_GlyphMap {
class CFX_CTTGSUBTable {
public:
- CFX_CTTGSUBTable(void) : m_bFeautureMapLoad(FALSE), loaded(false) {}
- CFX_CTTGSUBTable(FT_Bytes gsub) : m_bFeautureMapLoad(FALSE), loaded(false) {
- LoadGSUBTable(gsub);
- }
- virtual ~CFX_CTTGSUBTable() {}
- bool IsOk(void) const { return loaded; }
+ CFX_CTTGSUBTable();
+ explicit CFX_CTTGSUBTable(FT_Bytes gsub);
+ virtual ~CFX_CTTGSUBTable();
+
+ bool IsOk(void) const;
bool LoadGSUBTable(FT_Bytes gsub);
bool GetVerticalGlyph(uint32_t glyphnum, uint32_t* vglyphnum);
@@ -45,10 +45,6 @@ class CFX_CTTGSUBTable {
uint16_t LookupList;
};
struct TLangSys {
- uint16_t LookupOrder;
- uint16_t ReqFeatureIndex;
- uint16_t FeatureCount;
- uint16_t* FeatureIndex;
TLangSys()
: LookupOrder(0),
ReqFeatureIndex(0),
@@ -56,75 +52,88 @@ class CFX_CTTGSUBTable {
FeatureIndex(nullptr) {}
~TLangSys() { delete[] FeatureIndex; }
+ uint16_t LookupOrder;
+ uint16_t ReqFeatureIndex;
+ uint16_t FeatureCount;
+ uint16_t* FeatureIndex;
+
private:
TLangSys(const TLangSys&);
TLangSys& operator=(const TLangSys&);
};
struct TLangSysRecord {
+ TLangSysRecord() : LangSysTag(0) {}
+
uint32_t LangSysTag;
struct TLangSys LangSys;
- TLangSysRecord() : LangSysTag(0) {}
private:
TLangSysRecord(const TLangSysRecord&);
TLangSysRecord& operator=(const TLangSysRecord&);
};
struct TScript {
+ TScript() : DefaultLangSys(0), LangSysCount(0), LangSysRecord(nullptr) {}
+ ~TScript() { delete[] LangSysRecord; }
+
uint16_t DefaultLangSys;
uint16_t LangSysCount;
+ // TODO(weili): Replace with a smart pointer type, pdfium:518.
struct TLangSysRecord* LangSysRecord;
- TScript() : DefaultLangSys(0), LangSysCount(0), LangSysRecord(nullptr) {}
- ~TScript() { delete[] LangSysRecord; }
private:
TScript(const TScript&);
TScript& operator=(const TScript&);
};
struct TScriptRecord {
+ TScriptRecord() : ScriptTag(0) {}
+
uint32_t ScriptTag;
struct TScript Script;
- TScriptRecord() : ScriptTag(0) {}
private:
TScriptRecord(const TScriptRecord&);
TScriptRecord& operator=(const TScriptRecord&);
};
struct TScriptList {
- uint16_t ScriptCount;
- struct TScriptRecord* ScriptRecord;
TScriptList() : ScriptCount(0), ScriptRecord(nullptr) {}
~TScriptList() { delete[] ScriptRecord; }
+ uint16_t ScriptCount;
+ struct TScriptRecord* ScriptRecord;
+
private:
TScriptList(const TScriptList&);
TScriptList& operator=(const TScriptList&);
};
struct TFeature {
+ TFeature() : FeatureParams(0), LookupCount(0), LookupListIndex(nullptr) {}
+ ~TFeature() { delete[] LookupListIndex; }
+
uint16_t FeatureParams;
int LookupCount;
uint16_t* LookupListIndex;
- TFeature() : FeatureParams(0), LookupCount(0), LookupListIndex(nullptr) {}
- ~TFeature() { delete[] LookupListIndex; }
private:
TFeature(const TFeature&);
TFeature& operator=(const TFeature&);
};
struct TFeatureRecord {
+ TFeatureRecord() : FeatureTag(0) {}
+
uint32_t FeatureTag;
struct TFeature Feature;
- TFeatureRecord() : FeatureTag(0) {}
private:
TFeatureRecord(const TFeatureRecord&);
TFeatureRecord& operator=(const TFeatureRecord&);
};
struct TFeatureList {
- int FeatureCount;
- struct TFeatureRecord* FeatureRecord;
TFeatureList() : FeatureCount(0), FeatureRecord(nullptr) {}
~TFeatureList() { delete[] FeatureRecord; }
+ int FeatureCount;
+ struct TFeatureRecord* FeatureRecord;
+
private:
TFeatureList(const TFeatureList&);
TFeatureList& operator=(const TFeatureList&);
@@ -138,173 +147,165 @@ class CFX_CTTGSUBTable {
LOOKUPFLAG_MarkAttachmentType = 0xFF00,
};
struct TCoverageFormatBase {
- uint16_t CoverageFormat;
- CFX_GlyphMap m_glyphMap;
TCoverageFormatBase() : CoverageFormat(0) {}
virtual ~TCoverageFormatBase() {}
+ uint16_t CoverageFormat;
+ CFX_GlyphMap m_glyphMap;
+
private:
TCoverageFormatBase(const TCoverageFormatBase&);
TCoverageFormatBase& operator=(const TCoverageFormatBase&);
};
struct TCoverageFormat1 : public TCoverageFormatBase {
+ TCoverageFormat1();
+ ~TCoverageFormat1() override;
+
uint16_t GlyphCount;
uint16_t* GlyphArray;
- TCoverageFormat1() : GlyphCount(0), GlyphArray(nullptr) {
- CoverageFormat = 1;
- }
- ~TCoverageFormat1() override { delete[] GlyphArray; }
private:
TCoverageFormat1(const TCoverageFormat1&);
TCoverageFormat1& operator=(const TCoverageFormat1&);
};
struct TRangeRecord {
- uint16_t Start;
- uint16_t End;
- uint16_t StartCoverageIndex;
- TRangeRecord() : Start(0), End(0), StartCoverageIndex(0) {}
+ TRangeRecord();
+
friend bool operator>(const TRangeRecord& r1, const TRangeRecord& r2) {
return r1.Start > r2.Start;
}
+ uint16_t Start;
+ uint16_t End;
+ uint16_t StartCoverageIndex;
+
private:
TRangeRecord(const TRangeRecord&);
};
struct TCoverageFormat2 : public TCoverageFormatBase {
+ TCoverageFormat2();
+ ~TCoverageFormat2() override;
+
uint16_t RangeCount;
struct TRangeRecord* RangeRecord;
- TCoverageFormat2() : RangeCount(0), RangeRecord(nullptr) {
- CoverageFormat = 2;
- }
- ~TCoverageFormat2() override { delete[] RangeRecord; }
private:
TCoverageFormat2(const TCoverageFormat2&);
TCoverageFormat2& operator=(const TCoverageFormat2&);
};
struct TClassDefFormatBase {
- uint16_t ClassFormat;
TClassDefFormatBase() : ClassFormat(0) {}
virtual ~TClassDefFormatBase() {}
+ uint16_t ClassFormat;
+
private:
TClassDefFormatBase(const TClassDefFormatBase&);
TClassDefFormatBase& operator=(const TClassDefFormatBase&);
};
struct TClassDefFormat1 : public TClassDefFormatBase {
+ TClassDefFormat1();
+ ~TClassDefFormat1() override;
+
uint16_t StartGlyph;
uint16_t GlyphCount;
uint16_t* ClassValueArray;
- TClassDefFormat1()
- : StartGlyph(0), GlyphCount(0), ClassValueArray(nullptr) {
- ClassFormat = 1;
- }
- ~TClassDefFormat1() override { delete[] ClassValueArray; }
private:
TClassDefFormat1(const TClassDefFormat1&);
TClassDefFormat1& operator=(const TClassDefFormat1&);
};
struct TClassRangeRecord {
+ TClassRangeRecord() : Start(0), End(0), Class(0) {}
+
uint16_t Start;
uint16_t End;
uint16_t Class;
- TClassRangeRecord() : Start(0), End(0), Class(0) {}
private:
TClassRangeRecord(const TClassRangeRecord&);
TClassRangeRecord& operator=(const TClassRangeRecord&);
};
struct TClassDefFormat2 : public TClassDefFormatBase {
+ TClassDefFormat2();
+ ~TClassDefFormat2() override;
+
uint16_t ClassRangeCount;
struct TClassRangeRecord* ClassRangeRecord;
- TClassDefFormat2() : ClassRangeCount(0), ClassRangeRecord(nullptr) {
- ClassFormat = 2;
- }
- ~TClassDefFormat2() override { delete[] ClassRangeRecord; }
private:
TClassDefFormat2(const TClassDefFormat2&);
TClassDefFormat2& operator=(const TClassDefFormat2&);
};
struct TDevice {
+ TDevice() : StartSize(0), EndSize(0), DeltaFormat(0) {}
+
uint16_t StartSize;
uint16_t EndSize;
uint16_t DeltaFormat;
- TDevice() : StartSize(0), EndSize(0), DeltaFormat(0) {}
private:
TDevice(const TDevice&);
TDevice& operator=(const TDevice&);
};
struct TSubTableBase {
- uint16_t SubstFormat;
TSubTableBase() : SubstFormat(0) {}
virtual ~TSubTableBase() {}
+ uint16_t SubstFormat;
+
private:
TSubTableBase(const TSubTableBase&);
TSubTableBase& operator=(const TSubTableBase&);
};
struct TSingleSubstFormat1 : public TSubTableBase {
+ TSingleSubstFormat1();
+ ~TSingleSubstFormat1() override;
+
TCoverageFormatBase* Coverage;
int16_t DeltaGlyphID;
- TSingleSubstFormat1() : Coverage(nullptr), DeltaGlyphID(0) {
- SubstFormat = 1;
- }
- ~TSingleSubstFormat1() override { delete Coverage; }
private:
TSingleSubstFormat1(const TSingleSubstFormat1&);
TSingleSubstFormat1& operator=(const TSingleSubstFormat1&);
};
struct TSingleSubstFormat2 : public TSubTableBase {
+ TSingleSubstFormat2();
+ ~TSingleSubstFormat2() override;
+
TCoverageFormatBase* Coverage;
uint16_t GlyphCount;
uint16_t* Substitute;
- TSingleSubstFormat2()
- : Coverage(nullptr), GlyphCount(0), Substitute(nullptr) {
- SubstFormat = 2;
- }
- ~TSingleSubstFormat2() override {
- delete Coverage;
- delete[] Substitute;
- }
private:
TSingleSubstFormat2(const TSingleSubstFormat2&);
TSingleSubstFormat2& operator=(const TSingleSubstFormat2&);
};
struct TLookup {
+ TLookup();
+ ~TLookup();
+
uint16_t LookupType;
uint16_t LookupFlag;
uint16_t SubTableCount;
struct TSubTableBase** SubTable;
- TLookup()
- : LookupType(0), LookupFlag(0), SubTableCount(0), SubTable(nullptr) {}
- ~TLookup() {
- if (SubTable) {
- for (int i = 0; i < SubTableCount; ++i)
- delete SubTable[i];
- delete[] SubTable;
- }
- }
private:
TLookup(const TLookup&);
TLookup& operator=(const TLookup&);
};
struct TLookupList {
- int LookupCount;
- struct TLookup* Lookup;
TLookupList() : LookupCount(0), Lookup(nullptr) {}
~TLookupList() { delete[] Lookup; }
+ int LookupCount;
+ struct TLookup* Lookup;
+
private:
TLookupList(const TLookupList&);
TLookupList& operator=(const TLookupList&);
};
+
bool Parse(FT_Bytes scriptlist, FT_Bytes featurelist, FT_Bytes lookuplist);
void ParseScriptList(FT_Bytes raw, TScriptList* rec);
void ParseScript(FT_Bytes raw, TScript* rec);
@@ -319,38 +320,21 @@ class CFX_CTTGSUBTable {
void ParseSingleSubst(FT_Bytes raw, TSubTableBase** rec);
void ParseSingleSubstFormat1(FT_Bytes raw, TSingleSubstFormat1* rec);
void ParseSingleSubstFormat2(FT_Bytes raw, TSingleSubstFormat2* rec);
+
bool GetVerticalGlyphSub(uint32_t glyphnum,
uint32_t* vglyphnum,
- struct TFeature* Feature);
+ struct TFeature* Feature) const;
bool GetVerticalGlyphSub2(uint32_t glyphnum,
uint32_t* vglyphnum,
- struct TLookup* Lookup);
- int GetCoverageIndex(struct TCoverageFormatBase* Coverage, uint32_t g);
- uint8_t GetUInt8(FT_Bytes& p) const {
- uint8_t ret = p[0];
- p += 1;
- return ret;
- }
- int16_t GetInt16(FT_Bytes& p) const {
- uint16_t ret = p[0] << 8 | p[1];
- p += 2;
- return *(int16_t*)&ret;
- }
- uint16_t GetUInt16(FT_Bytes& p) const {
- uint16_t ret = p[0] << 8 | p[1];
- p += 2;
- return ret;
- }
- int32_t GetInt32(FT_Bytes& p) const {
- uint32_t ret = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
- p += 4;
- return *(int32_t*)&ret;
- }
- uint32_t GetUInt32(FT_Bytes& p) const {
- uint32_t ret = p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3];
- p += 4;
- return ret;
- }
+ struct TLookup* Lookup) const;
+ int GetCoverageIndex(struct TCoverageFormatBase* Coverage, uint32_t g) const;
+
+ uint8_t GetUInt8(FT_Bytes& p) const;
+ int16_t GetInt16(FT_Bytes& p) const;
+ uint16_t GetUInt16(FT_Bytes& p) const;
+ int32_t GetInt32(FT_Bytes& p) const;
+ uint32_t GetUInt32(FT_Bytes& p) const;
+
std::map<uint32_t, uint32_t> m_featureMap;
FX_BOOL m_bFeautureMapLoad;
bool loaded;
diff --git a/core/fpdfapi/fpdf_page/cpdf_allstates.h b/core/fpdfapi/fpdf_page/cpdf_allstates.h
index 9af917a113..21fd6c2d9b 100644
--- a/core/fpdfapi/fpdf_page/cpdf_allstates.h
+++ b/core/fpdfapi/fpdf_page/cpdf_allstates.h
@@ -18,7 +18,7 @@ class CPDF_StreamContentParser;
class CPDF_AllStates : public CPDF_GraphicStates {
public:
CPDF_AllStates();
- ~CPDF_AllStates();
+ ~CPDF_AllStates() override;
void Copy(const CPDF_AllStates& src);
void ProcessExtGS(CPDF_Dictionary* pGS, CPDF_StreamContentParser* pParser);
diff --git a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp
index 9300f1081b..9d3aeb2adc 100644
--- a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp
@@ -436,6 +436,13 @@ FX_BOOL CPDF_ColorSpace::sRGB() const {
return pCS->m_pProfile->m_bsRGB;
}
+FX_BOOL CPDF_ColorSpace::SetRGB(FX_FLOAT* pBuf,
+ FX_FLOAT R,
+ FX_FLOAT G,
+ FX_FLOAT B) const {
+ return FALSE;
+}
+
FX_BOOL CPDF_ColorSpace::GetCMYK(FX_FLOAT* pBuf,
FX_FLOAT& c,
FX_FLOAT& m,
@@ -475,6 +482,19 @@ void CPDF_ColorSpace::GetDefaultColor(FX_FLOAT* buf) const {
}
}
+uint32_t CPDF_ColorSpace::CountComponents() const {
+ return m_nComponents;
+}
+
+void CPDF_ColorSpace::GetDefaultValue(int iComponent,
+ FX_FLOAT& value,
+ FX_FLOAT& min,
+ FX_FLOAT& max) const {
+ value = 0;
+ min = 0;
+ max = 1.0f;
+}
+
void CPDF_ColorSpace::TranslateImageLine(uint8_t* dest_buf,
const uint8_t* src_buf,
int pixels,
@@ -498,6 +518,10 @@ void CPDF_ColorSpace::TranslateImageLine(uint8_t* dest_buf,
}
}
+CPDF_ColorSpace* CPDF_ColorSpace::GetBaseCS() const {
+ return nullptr;
+}
+
void CPDF_ColorSpace::EnableStdConversion(FX_BOOL bEnabled) {
if (bEnabled)
m_dwStdConversion++;
@@ -505,6 +529,37 @@ void CPDF_ColorSpace::EnableStdConversion(FX_BOOL bEnabled) {
m_dwStdConversion--;
}
+CPDF_ColorSpace::CPDF_ColorSpace(CPDF_Document* pDoc,
+ int family,
+ uint32_t nComponents)
+ : m_pDocument(pDoc),
+ m_Family(family),
+ m_nComponents(nComponents),
+ m_pArray(nullptr),
+ m_dwStdConversion(0) {}
+
+CPDF_ColorSpace::~CPDF_ColorSpace() {}
+
+FX_BOOL CPDF_ColorSpace::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) {
+ return TRUE;
+}
+
+FX_BOOL CPDF_ColorSpace::v_GetCMYK(FX_FLOAT* pBuf,
+ FX_FLOAT& c,
+ FX_FLOAT& m,
+ FX_FLOAT& y,
+ FX_FLOAT& k) const {
+ return FALSE;
+}
+
+FX_BOOL CPDF_ColorSpace::v_SetCMYK(FX_FLOAT* pBuf,
+ FX_FLOAT c,
+ FX_FLOAT m,
+ FX_FLOAT y,
+ FX_FLOAT k) const {
+ return FALSE;
+}
+
CPDF_CalGray::CPDF_CalGray(CPDF_Document* pDoc)
: CPDF_ColorSpace(pDoc, PDFCS_CALGRAY, 1) {}
diff --git a/core/fpdfapi/fpdf_page/cpdf_contentmarkdata.cpp b/core/fpdfapi/fpdf_page/cpdf_contentmarkdata.cpp
index 076e8ac521..256e266b04 100644
--- a/core/fpdfapi/fpdf_page/cpdf_contentmarkdata.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_contentmarkdata.cpp
@@ -9,13 +9,25 @@
#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
#include "third_party/base/stl_util.h"
+CPDF_ContentMarkData::CPDF_ContentMarkData() {}
+
CPDF_ContentMarkData::CPDF_ContentMarkData(const CPDF_ContentMarkData& src)
: m_Marks(src.m_Marks) {}
+CPDF_ContentMarkData::~CPDF_ContentMarkData() {}
+
int CPDF_ContentMarkData::CountItems() const {
return pdfium::CollectionSize<int>(m_Marks);
}
+CPDF_ContentMarkItem& CPDF_ContentMarkData::GetItem(int index) {
+ return m_Marks[index];
+}
+
+const CPDF_ContentMarkItem& CPDF_ContentMarkData::GetItem(int index) const {
+ return m_Marks[index];
+}
+
int CPDF_ContentMarkData::GetMCID() const {
for (const auto& mark : m_Marks) {
CPDF_ContentMarkItem::ParamType type = mark.GetParamType();
diff --git a/core/fpdfapi/fpdf_page/cpdf_contentmarkdata.h b/core/fpdfapi/fpdf_page/cpdf_contentmarkdata.h
index 773fea741b..6f5c1f1fae 100644
--- a/core/fpdfapi/fpdf_page/cpdf_contentmarkdata.h
+++ b/core/fpdfapi/fpdf_page/cpdf_contentmarkdata.h
@@ -16,14 +16,13 @@ class CPDF_Dictionary;
class CPDF_ContentMarkData {
public:
- CPDF_ContentMarkData() {}
+ CPDF_ContentMarkData();
CPDF_ContentMarkData(const CPDF_ContentMarkData& src);
+ ~CPDF_ContentMarkData();
int CountItems() const;
- CPDF_ContentMarkItem& GetItem(int index) { return m_Marks[index]; }
- const CPDF_ContentMarkItem& GetItem(int index) const {
- return m_Marks[index];
- }
+ CPDF_ContentMarkItem& GetItem(int index);
+ const CPDF_ContentMarkItem& GetItem(int index) const;
int GetMCID() const;
void AddMark(const CFX_ByteString& name,
diff --git a/core/fpdfapi/fpdf_page/cpdf_formobject.cpp b/core/fpdfapi/fpdf_page/cpdf_formobject.cpp
index d85ff7dbb3..567c156af0 100644
--- a/core/fpdfapi/fpdf_page/cpdf_formobject.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_formobject.cpp
@@ -19,6 +19,18 @@ void CPDF_FormObject::Transform(const CFX_Matrix& matrix) {
CalcBoundingBox();
}
+bool CPDF_FormObject::IsForm() const {
+ return true;
+}
+
+CPDF_FormObject* CPDF_FormObject::AsForm() {
+ return this;
+}
+
+const CPDF_FormObject* CPDF_FormObject::AsForm() const {
+ return this;
+}
+
CPDF_FormObject* CPDF_FormObject::Clone() const {
CPDF_FormObject* obj = new CPDF_FormObject;
obj->CopyData(this);
@@ -28,6 +40,10 @@ CPDF_FormObject* CPDF_FormObject::Clone() const {
return obj;
}
+CPDF_PageObject::Type CPDF_FormObject::GetType() const {
+ return FORM;
+}
+
void CPDF_FormObject::CalcBoundingBox() {
CFX_FloatRect form_rect = m_pForm->CalcBoundingBox();
form_rect.Transform(&m_FormMatrix);
diff --git a/core/fpdfapi/fpdf_page/cpdf_graphicstates.cpp b/core/fpdfapi/fpdf_page/cpdf_graphicstates.cpp
index 9c540941ce..fc054caf21 100644
--- a/core/fpdfapi/fpdf_page/cpdf_graphicstates.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_graphicstates.cpp
@@ -6,6 +6,10 @@
#include "core/fpdfapi/fpdf_page/cpdf_graphicstates.h"
+CPDF_GraphicStates::CPDF_GraphicStates() {}
+
+CPDF_GraphicStates::~CPDF_GraphicStates() {}
+
void CPDF_GraphicStates::DefaultStates() {
m_ColorState.New()->Default();
}
diff --git a/core/fpdfapi/fpdf_page/cpdf_graphicstates.h b/core/fpdfapi/fpdf_page/cpdf_graphicstates.h
index 0add18c910..a408bc794b 100644
--- a/core/fpdfapi/fpdf_page/cpdf_graphicstates.h
+++ b/core/fpdfapi/fpdf_page/cpdf_graphicstates.h
@@ -15,6 +15,9 @@
class CPDF_GraphicStates {
public:
+ CPDF_GraphicStates();
+ virtual ~CPDF_GraphicStates();
+
void CopyStates(const CPDF_GraphicStates& src);
void DefaultStates();
diff --git a/core/fpdfapi/fpdf_page/cpdf_imageobject.cpp b/core/fpdfapi/fpdf_page/cpdf_imageobject.cpp
index 6203d56273..e2defa8054 100644
--- a/core/fpdfapi/fpdf_page/cpdf_imageobject.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_imageobject.cpp
@@ -33,11 +33,27 @@ CPDF_ImageObject* CPDF_ImageObject::Clone() const {
return obj;
}
+CPDF_PageObject::Type CPDF_ImageObject::GetType() const {
+ return IMAGE;
+}
+
void CPDF_ImageObject::Transform(const CFX_Matrix& matrix) {
m_Matrix.Concat(matrix);
CalcBoundingBox();
}
+bool CPDF_ImageObject::IsImage() const {
+ return true;
+}
+
+CPDF_ImageObject* CPDF_ImageObject::AsImage() {
+ return this;
+}
+
+const CPDF_ImageObject* CPDF_ImageObject::AsImage() const {
+ return this;
+}
+
void CPDF_ImageObject::CalcBoundingBox() {
m_Left = m_Bottom = 0;
m_Right = m_Top = 1.0f;
diff --git a/core/fpdfapi/fpdf_page/cpdf_pagemodule.cpp b/core/fpdfapi/fpdf_page/cpdf_pagemodule.cpp
index 0d2f547835..c22c8fbc46 100644
--- a/core/fpdfapi/fpdf_page/cpdf_pagemodule.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_pagemodule.cpp
@@ -6,6 +6,18 @@
#include "core/fpdfapi/fpdf_page/cpdf_pagemodule.h"
+CPDF_PageModule::CPDF_PageModule()
+ : m_StockGrayCS(nullptr, PDFCS_DEVICEGRAY),
+ m_StockRGBCS(nullptr, PDFCS_DEVICERGB),
+ m_StockCMYKCS(nullptr, PDFCS_DEVICECMYK),
+ m_StockPatternCS(nullptr) {}
+
+CPDF_PageModule::~CPDF_PageModule() {}
+
+CPDF_FontGlobals* CPDF_PageModule::GetFontGlobals() {
+ return &m_FontGlobals;
+}
+
CPDF_ColorSpace* CPDF_PageModule::GetStockCS(int family) {
if (family == PDFCS_DEVICEGRAY)
return &m_StockGrayCS;
@@ -17,3 +29,7 @@ CPDF_ColorSpace* CPDF_PageModule::GetStockCS(int family) {
return &m_StockPatternCS;
return nullptr;
}
+
+void CPDF_PageModule::ClearStockFont(CPDF_Document* pDoc) {
+ m_FontGlobals.Clear(pDoc);
+}
diff --git a/core/fpdfapi/fpdf_page/cpdf_pagemodule.h b/core/fpdfapi/fpdf_page/cpdf_pagemodule.h
index c609de9c58..2e418f8993 100644
--- a/core/fpdfapi/fpdf_page/cpdf_pagemodule.h
+++ b/core/fpdfapi/fpdf_page/cpdf_pagemodule.h
@@ -15,16 +15,12 @@ class CPDF_Document;
class CPDF_PageModule {
public:
- CPDF_PageModule()
- : m_StockGrayCS(nullptr, PDFCS_DEVICEGRAY),
- m_StockRGBCS(nullptr, PDFCS_DEVICERGB),
- m_StockCMYKCS(nullptr, PDFCS_DEVICECMYK),
- m_StockPatternCS(nullptr) {}
- ~CPDF_PageModule() {}
-
- CPDF_FontGlobals* GetFontGlobals() { return &m_FontGlobals; }
+ CPDF_PageModule();
+ ~CPDF_PageModule();
+
+ CPDF_FontGlobals* GetFontGlobals();
CPDF_ColorSpace* GetStockCS(int family);
- void ClearStockFont(CPDF_Document* pDoc) { m_FontGlobals.Clear(pDoc); }
+ void ClearStockFont(CPDF_Document* pDoc);
private:
CPDF_FontGlobals m_FontGlobals;
diff --git a/core/fpdfapi/fpdf_page/cpdf_pageobject.cpp b/core/fpdfapi/fpdf_page/cpdf_pageobject.cpp
index ee6615e2e7..ebac18a596 100644
--- a/core/fpdfapi/fpdf_page/cpdf_pageobject.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_pageobject.cpp
@@ -10,6 +10,66 @@ CPDF_PageObject::CPDF_PageObject() {}
CPDF_PageObject::~CPDF_PageObject() {}
+bool CPDF_PageObject::IsText() const {
+ return false;
+}
+
+bool CPDF_PageObject::IsPath() const {
+ return false;
+}
+
+bool CPDF_PageObject::IsImage() const {
+ return false;
+}
+
+bool CPDF_PageObject::IsShading() const {
+ return false;
+}
+
+bool CPDF_PageObject::IsForm() const {
+ return false;
+}
+
+CPDF_TextObject* CPDF_PageObject::AsText() {
+ return nullptr;
+}
+
+const CPDF_TextObject* CPDF_PageObject::AsText() const {
+ return nullptr;
+}
+
+CPDF_PathObject* CPDF_PageObject::AsPath() {
+ return nullptr;
+}
+
+const CPDF_PathObject* CPDF_PageObject::AsPath() const {
+ return nullptr;
+}
+
+CPDF_ImageObject* CPDF_PageObject::AsImage() {
+ return nullptr;
+}
+
+const CPDF_ImageObject* CPDF_PageObject::AsImage() const {
+ return nullptr;
+}
+
+CPDF_ShadingObject* CPDF_PageObject::AsShading() {
+ return nullptr;
+}
+
+const CPDF_ShadingObject* CPDF_PageObject::AsShading() const {
+ return nullptr;
+}
+
+CPDF_FormObject* CPDF_PageObject::AsForm() {
+ return nullptr;
+}
+
+const CPDF_FormObject* CPDF_PageObject::AsForm() const {
+ return nullptr;
+}
+
void CPDF_PageObject::CopyData(const CPDF_PageObject* pSrc) {
CopyStates(*pSrc);
m_Left = pSrc->m_Left;
diff --git a/core/fpdfapi/fpdf_page/cpdf_pageobjectholder.cpp b/core/fpdfapi/fpdf_page/cpdf_pageobjectholder.cpp
index cd6eca5adc..77ec205518 100644
--- a/core/fpdfapi/fpdf_page/cpdf_pageobjectholder.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_pageobjectholder.cpp
@@ -21,6 +21,8 @@ CPDF_PageObjectHolder::CPDF_PageObjectHolder()
m_bHasImageMask(FALSE),
m_ParseState(CONTENT_NOT_PARSED) {}
+CPDF_PageObjectHolder::~CPDF_PageObjectHolder() {}
+
void CPDF_PageObjectHolder::ContinueParse(IFX_Pause* pPause) {
if (!m_pParser) {
return;
diff --git a/core/fpdfapi/fpdf_page/cpdf_pathobject.cpp b/core/fpdfapi/fpdf_page/cpdf_pathobject.cpp
index cfe7b48c8b..b62a5bd25a 100644
--- a/core/fpdfapi/fpdf_page/cpdf_pathobject.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_pathobject.cpp
@@ -21,11 +21,27 @@ CPDF_PathObject* CPDF_PathObject::Clone() const {
return obj;
}
+CPDF_PageObject::Type CPDF_PathObject::GetType() const {
+ return PATH;
+}
+
void CPDF_PathObject::Transform(const CFX_Matrix& matrix) {
m_Matrix.Concat(matrix);
CalcBoundingBox();
}
+bool CPDF_PathObject::IsPath() const {
+ return true;
+}
+
+CPDF_PathObject* CPDF_PathObject::AsPath() {
+ return this;
+}
+
+const CPDF_PathObject* CPDF_PathObject::AsPath() const {
+ return this;
+}
+
void CPDF_PathObject::CalcBoundingBox() {
if (m_Path.IsNull()) {
return;
diff --git a/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp b/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp
index de84f29865..b2eb5e642c 100644
--- a/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_shadingobject.cpp
@@ -30,6 +30,10 @@ CPDF_ShadingObject* CPDF_ShadingObject::Clone() const {
return obj;
}
+CPDF_PageObject::Type CPDF_ShadingObject::GetType() const {
+ return SHADING;
+}
+
void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) {
if (!m_ClipPath.IsNull()) {
m_ClipPath.GetModify();
@@ -43,6 +47,18 @@ void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) {
}
}
+bool CPDF_ShadingObject::IsShading() const {
+ return true;
+}
+
+CPDF_ShadingObject* CPDF_ShadingObject::AsShading() {
+ return this;
+}
+
+const CPDF_ShadingObject* CPDF_ShadingObject::AsShading() const {
+ return this;
+}
+
void CPDF_ShadingObject::CalcBoundingBox() {
if (m_ClipPath.IsNull()) {
return;
diff --git a/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp b/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp
index 1636e17f4f..e2205f956d 100644
--- a/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp
@@ -50,6 +50,14 @@ CPDF_ShadingPattern::~CPDF_ShadingPattern() {
m_pDocument->GetPageData()->ReleaseColorSpace(pCS->GetArray());
}
+CPDF_TilingPattern* CPDF_ShadingPattern::AsTilingPattern() {
+ return nullptr;
+}
+
+CPDF_ShadingPattern* CPDF_ShadingPattern::AsShadingPattern() {
+ return this;
+}
+
bool CPDF_ShadingPattern::Load() {
if (m_ShadingType != kInvalidShading)
return TRUE;
diff --git a/core/fpdfapi/fpdf_page/cpdf_shadingpattern.h b/core/fpdfapi/fpdf_page/cpdf_shadingpattern.h
index f5cef17fb1..7fe2cc6c79 100644
--- a/core/fpdfapi/fpdf_page/cpdf_shadingpattern.h
+++ b/core/fpdfapi/fpdf_page/cpdf_shadingpattern.h
@@ -40,8 +40,8 @@ class CPDF_ShadingPattern : public CPDF_Pattern {
const CFX_Matrix& parentMatrix);
~CPDF_ShadingPattern() override;
- CPDF_TilingPattern* AsTilingPattern() override { return nullptr; }
- CPDF_ShadingPattern* AsShadingPattern() override { return this; }
+ CPDF_TilingPattern* AsTilingPattern() override;
+ CPDF_ShadingPattern* AsShadingPattern() override;
bool IsMeshShading() const {
return m_ShadingType == kFreeFormGouraudTriangleMeshShading ||
diff --git a/core/fpdfapi/fpdf_page/cpdf_textobject.cpp b/core/fpdfapi/fpdf_page/cpdf_textobject.cpp
index 72658c67ba..caa7d0df56 100644
--- a/core/fpdfapi/fpdf_page/cpdf_textobject.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_textobject.cpp
@@ -23,6 +23,10 @@ CPDF_TextObject::~CPDF_TextObject() {
FX_Free(m_pCharPos);
}
+int CPDF_TextObject::CountItems() const {
+ return m_nChars;
+}
+
void CPDF_TextObject::GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const {
pInfo->m_CharCode =
m_nChars == 1 ? (uint32_t)(uintptr_t)m_pCharCodes : m_pCharCodes[index];
@@ -124,6 +128,37 @@ CPDF_TextObject* CPDF_TextObject::Clone() const {
return obj;
}
+CPDF_PageObject::Type CPDF_TextObject::GetType() const {
+ return TEXT;
+}
+
+void CPDF_TextObject::Transform(const CFX_Matrix& matrix) {
+ m_TextState.GetModify();
+ CFX_Matrix text_matrix;
+ GetTextMatrix(&text_matrix);
+ text_matrix.Concat(matrix);
+ FX_FLOAT* pTextMatrix = m_TextState.GetMatrix();
+ pTextMatrix[0] = text_matrix.GetA();
+ pTextMatrix[1] = text_matrix.GetC();
+ pTextMatrix[2] = text_matrix.GetB();
+ pTextMatrix[3] = text_matrix.GetD();
+ m_PosX = text_matrix.GetE();
+ m_PosY = text_matrix.GetF();
+ CalcPositionData(nullptr, nullptr, 0);
+}
+
+bool CPDF_TextObject::IsText() const {
+ return true;
+}
+
+CPDF_TextObject* CPDF_TextObject::AsText() {
+ return this;
+}
+
+const CPDF_TextObject* CPDF_TextObject::AsText() const {
+ return this;
+}
+
void CPDF_TextObject::GetTextMatrix(CFX_Matrix* pMatrix) const {
FX_FLOAT* pTextMatrix = m_TextState.GetMatrix();
pMatrix->Set(pTextMatrix[0], pTextMatrix[2], pTextMatrix[1], pTextMatrix[3],
@@ -188,6 +223,22 @@ FX_FLOAT CPDF_TextObject::GetCharWidth(uint32_t charcode) const {
return pCIDFont->GetVertWidth(CID) * fontsize;
}
+FX_FLOAT CPDF_TextObject::GetPosX() const {
+ return m_PosX;
+}
+
+FX_FLOAT CPDF_TextObject::GetPosY() const {
+ return m_PosY;
+}
+
+CPDF_Font* CPDF_TextObject::GetFont() const {
+ return m_TextState.GetFont();
+}
+
+FX_FLOAT CPDF_TextObject::GetFontSize() const {
+ return m_TextState.GetFontSize();
+}
+
void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX,
FX_FLOAT* pTextAdvanceY,
FX_FLOAT horz_scale,
@@ -322,21 +373,6 @@ void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX,
}
}
-void CPDF_TextObject::Transform(const CFX_Matrix& matrix) {
- m_TextState.GetModify();
- CFX_Matrix text_matrix;
- GetTextMatrix(&text_matrix);
- text_matrix.Concat(matrix);
- FX_FLOAT* pTextMatrix = m_TextState.GetMatrix();
- pTextMatrix[0] = text_matrix.GetA();
- pTextMatrix[1] = text_matrix.GetC();
- pTextMatrix[2] = text_matrix.GetB();
- pTextMatrix[3] = text_matrix.GetD();
- m_PosX = text_matrix.GetE();
- m_PosY = text_matrix.GetF();
- CalcPositionData(nullptr, nullptr, 0);
-}
-
void CPDF_TextObject::SetPosition(FX_FLOAT x, FX_FLOAT y) {
FX_FLOAT dx = x - m_PosX;
FX_FLOAT dy = y - m_PosY;
@@ -347,3 +383,7 @@ void CPDF_TextObject::SetPosition(FX_FLOAT x, FX_FLOAT y) {
m_Top += dy;
m_Bottom += dy;
}
+
+void CPDF_TextObject::RecalcPositionData() {
+ CalcPositionData(nullptr, nullptr, 1);
+}
diff --git a/core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp b/core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp
index 0b1eeab9f4..f7370de0bc 100644
--- a/core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_tilingpattern.cpp
@@ -24,6 +24,14 @@ CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc,
CPDF_TilingPattern::~CPDF_TilingPattern() {
}
+CPDF_TilingPattern* CPDF_TilingPattern::AsTilingPattern() {
+ return this;
+}
+
+CPDF_ShadingPattern* CPDF_TilingPattern::AsShadingPattern() {
+ return nullptr;
+}
+
FX_BOOL CPDF_TilingPattern::Load() {
if (m_pForm)
return TRUE;
diff --git a/core/fpdfapi/fpdf_page/cpdf_tilingpattern.h b/core/fpdfapi/fpdf_page/cpdf_tilingpattern.h
index 3e62810363..abfd434274 100644
--- a/core/fpdfapi/fpdf_page/cpdf_tilingpattern.h
+++ b/core/fpdfapi/fpdf_page/cpdf_tilingpattern.h
@@ -24,8 +24,8 @@ class CPDF_TilingPattern : public CPDF_Pattern {
const CFX_Matrix& parentMatrix);
~CPDF_TilingPattern() override;
- CPDF_TilingPattern* AsTilingPattern() override { return this; }
- CPDF_ShadingPattern* AsShadingPattern() override { return nullptr; }
+ CPDF_TilingPattern* AsTilingPattern() override;
+ CPDF_ShadingPattern* AsShadingPattern() override;
FX_BOOL Load();
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h b/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h
index 8bb6c57260..fad85a147a 100644
--- a/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h
+++ b/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h
@@ -37,16 +37,12 @@ class CPDF_ColorSpace {
int GetBufSize() const;
FX_FLOAT* CreateBuf();
void GetDefaultColor(FX_FLOAT* buf) const;
- uint32_t CountComponents() const { return m_nComponents; }
+ uint32_t CountComponents() const;
int GetFamily() const { return m_Family; }
virtual void GetDefaultValue(int iComponent,
FX_FLOAT& value,
FX_FLOAT& min,
- FX_FLOAT& max) const {
- value = 0;
- min = 0;
- max = 1.0f;
- }
+ FX_FLOAT& max) const;
FX_BOOL sRGB() const;
virtual FX_BOOL GetRGB(FX_FLOAT* pBuf,
@@ -56,9 +52,7 @@ class CPDF_ColorSpace {
virtual FX_BOOL SetRGB(FX_FLOAT* pBuf,
FX_FLOAT R,
FX_FLOAT G,
- FX_FLOAT B) const {
- return FALSE;
- }
+ FX_FLOAT B) const;
FX_BOOL GetCMYK(FX_FLOAT* pBuf,
FX_FLOAT& c,
@@ -79,38 +73,27 @@ class CPDF_ColorSpace {
FX_BOOL bTransMask = FALSE) const;
CPDF_Array*& GetArray() { return m_pArray; }
- virtual CPDF_ColorSpace* GetBaseCS() const { return nullptr; }
+ virtual CPDF_ColorSpace* GetBaseCS() const;
virtual void EnableStdConversion(FX_BOOL bEnabled);
CPDF_Document* const m_pDocument;
protected:
- CPDF_ColorSpace(CPDF_Document* pDoc, int family, uint32_t nComponents)
- : m_pDocument(pDoc),
- m_Family(family),
- m_nComponents(nComponents),
- m_pArray(nullptr),
- m_dwStdConversion(0) {}
- virtual ~CPDF_ColorSpace() {}
-
- virtual FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) {
- return TRUE;
- }
+ CPDF_ColorSpace(CPDF_Document* pDoc, int family, uint32_t nComponents);
+ virtual ~CPDF_ColorSpace();
+
+ virtual FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray);
virtual FX_BOOL v_GetCMYK(FX_FLOAT* pBuf,
FX_FLOAT& c,
FX_FLOAT& m,
FX_FLOAT& y,
- FX_FLOAT& k) const {
- return FALSE;
- }
+ FX_FLOAT& k) const;
virtual FX_BOOL v_SetCMYK(FX_FLOAT* pBuf,
FX_FLOAT c,
FX_FLOAT m,
FX_FLOAT y,
- FX_FLOAT k) const {
- return FALSE;
- }
+ FX_FLOAT k) const;
int m_Family;
uint32_t m_nComponents;
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_form.h b/core/fpdfapi/fpdf_page/include/cpdf_form.h
index 92acbca25a..c2cba0eb13 100644
--- a/core/fpdfapi/fpdf_page/include/cpdf_form.h
+++ b/core/fpdfapi/fpdf_page/include/cpdf_form.h
@@ -22,8 +22,7 @@ class CPDF_Form : public CPDF_PageObjectHolder {
CPDF_Dictionary* pPageResources,
CPDF_Stream* pFormStream,
CPDF_Dictionary* pParentResources = nullptr);
-
- ~CPDF_Form();
+ ~CPDF_Form() override;
void ParseContent(CPDF_AllStates* pGraphicStates,
const CFX_Matrix* pParentMatrix,
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_formobject.h b/core/fpdfapi/fpdf_page/include/cpdf_formobject.h
index b12d68c312..1a8db34e8f 100644
--- a/core/fpdfapi/fpdf_page/include/cpdf_formobject.h
+++ b/core/fpdfapi/fpdf_page/include/cpdf_formobject.h
@@ -19,11 +19,11 @@ class CPDF_FormObject : public CPDF_PageObject {
// CPDF_PageObject:
CPDF_FormObject* Clone() const override;
- Type GetType() const override { return FORM; };
+ Type GetType() const override;
void Transform(const CFX_Matrix& matrix) override;
- bool IsForm() const override { return true; };
- CPDF_FormObject* AsForm() override { return this; };
- const CPDF_FormObject* AsForm() const override { return this; };
+ bool IsForm() const override;
+ CPDF_FormObject* AsForm() override;
+ const CPDF_FormObject* AsForm() const override;
void CalcBoundingBox();
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_imageobject.h b/core/fpdfapi/fpdf_page/include/cpdf_imageobject.h
index 9b983cc05c..1128d12f8b 100644
--- a/core/fpdfapi/fpdf_page/include/cpdf_imageobject.h
+++ b/core/fpdfapi/fpdf_page/include/cpdf_imageobject.h
@@ -17,13 +17,13 @@ class CPDF_ImageObject : public CPDF_PageObject {
CPDF_ImageObject();
~CPDF_ImageObject() override;
- // CPDF_PageObject:
+ // CPDF_PageObject
CPDF_ImageObject* Clone() const override;
- Type GetType() const override { return IMAGE; };
+ Type GetType() const override;
void Transform(const CFX_Matrix& matrix) override;
- bool IsImage() const override { return true; };
- CPDF_ImageObject* AsImage() override { return this; };
- const CPDF_ImageObject* AsImage() const override { return this; };
+ bool IsImage() const override;
+ CPDF_ImageObject* AsImage() override;
+ const CPDF_ImageObject* AsImage() const override;
void CalcBoundingBox();
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_page.h b/core/fpdfapi/fpdf_page/include/cpdf_page.h
index 99734889af..e73c41db79 100644
--- a/core/fpdfapi/fpdf_page/include/cpdf_page.h
+++ b/core/fpdfapi/fpdf_page/include/cpdf_page.h
@@ -26,7 +26,7 @@ class CPDF_Page : public CPDF_PageObjectHolder {
CPDF_Page(CPDF_Document* pDocument,
CPDF_Dictionary* pPageDict,
bool bPageCache);
- ~CPDF_Page();
+ ~CPDF_Page() override;
void ParseContent();
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_pageobject.h b/core/fpdfapi/fpdf_page/include/cpdf_pageobject.h
index 8e7da81e90..d9d584388e 100644
--- a/core/fpdfapi/fpdf_page/include/cpdf_pageobject.h
+++ b/core/fpdfapi/fpdf_page/include/cpdf_pageobject.h
@@ -29,26 +29,26 @@ class CPDF_PageObject : public CPDF_GraphicStates {
};
CPDF_PageObject();
- virtual ~CPDF_PageObject();
+ ~CPDF_PageObject() override;
virtual CPDF_PageObject* Clone() const = 0;
virtual Type GetType() const = 0;
virtual void Transform(const CFX_Matrix& matrix) = 0;
- virtual bool IsText() const { return false; }
- virtual bool IsPath() const { return false; }
- virtual bool IsImage() const { return false; }
- virtual bool IsShading() const { return false; }
- virtual bool IsForm() const { return false; }
- virtual CPDF_TextObject* AsText() { return nullptr; }
- virtual const CPDF_TextObject* AsText() const { return nullptr; }
- virtual CPDF_PathObject* AsPath() { return nullptr; }
- virtual const CPDF_PathObject* AsPath() const { return nullptr; }
- virtual CPDF_ImageObject* AsImage() { return nullptr; }
- virtual const CPDF_ImageObject* AsImage() const { return nullptr; }
- virtual CPDF_ShadingObject* AsShading() { return nullptr; }
- virtual const CPDF_ShadingObject* AsShading() const { return nullptr; }
- virtual CPDF_FormObject* AsForm() { return nullptr; }
- virtual const CPDF_FormObject* AsForm() const { return nullptr; }
+ virtual bool IsText() const;
+ virtual bool IsPath() const;
+ virtual bool IsImage() const;
+ virtual bool IsShading() const;
+ virtual bool IsForm() const;
+ virtual CPDF_TextObject* AsText();
+ virtual const CPDF_TextObject* AsText() const;
+ virtual CPDF_PathObject* AsPath();
+ virtual const CPDF_PathObject* AsPath() const;
+ virtual CPDF_ImageObject* AsImage();
+ virtual const CPDF_ImageObject* AsImage() const;
+ virtual CPDF_ShadingObject* AsShading();
+ virtual const CPDF_ShadingObject* AsShading() const;
+ virtual CPDF_FormObject* AsForm();
+ virtual const CPDF_FormObject* AsForm() const;
void TransformClipPath(CFX_Matrix& matrix);
void TransformGeneralState(CFX_Matrix& matrix);
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h b/core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h
index 7ac9f2cea0..e75604858a 100644
--- a/core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h
+++ b/core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h
@@ -24,6 +24,7 @@ class CPDF_ContentParser;
class CPDF_PageObjectHolder {
public:
CPDF_PageObjectHolder();
+ virtual ~CPDF_PageObjectHolder();
void ContinueParse(IFX_Pause* pPause);
bool IsParsed() const { return m_ParseState == CONTENT_PARSED; }
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_pathobject.h b/core/fpdfapi/fpdf_page/include/cpdf_pathobject.h
index 296cdf8317..10d101222a 100644
--- a/core/fpdfapi/fpdf_page/include/cpdf_pathobject.h
+++ b/core/fpdfapi/fpdf_page/include/cpdf_pathobject.h
@@ -17,13 +17,13 @@ class CPDF_PathObject : public CPDF_PageObject {
CPDF_PathObject();
~CPDF_PathObject() override;
- // CPDF_PageObject:
+ // CPDF_PageObject
CPDF_PathObject* Clone() const override;
- Type GetType() const override { return PATH; };
+ Type GetType() const override;
void Transform(const CFX_Matrix& maxtrix) override;
- bool IsPath() const override { return true; };
- CPDF_PathObject* AsPath() override { return this; };
- const CPDF_PathObject* AsPath() const override { return this; };
+ bool IsPath() const override;
+ CPDF_PathObject* AsPath() override;
+ const CPDF_PathObject* AsPath() const override;
void CalcBoundingBox();
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_shadingobject.h b/core/fpdfapi/fpdf_page/include/cpdf_shadingobject.h
index ae2ee90083..0607bcb42c 100644
--- a/core/fpdfapi/fpdf_page/include/cpdf_shadingobject.h
+++ b/core/fpdfapi/fpdf_page/include/cpdf_shadingobject.h
@@ -17,13 +17,13 @@ class CPDF_ShadingObject : public CPDF_PageObject {
CPDF_ShadingObject();
~CPDF_ShadingObject() override;
- // CPDF_PageObject:
+ // CPDF_PageObject
CPDF_ShadingObject* Clone() const override;
- Type GetType() const override { return SHADING; };
+ Type GetType() const override;
void Transform(const CFX_Matrix& matrix) override;
- bool IsShading() const override { return true; };
- CPDF_ShadingObject* AsShading() override { return this; };
- const CPDF_ShadingObject* AsShading() const override { return this; };
+ bool IsShading() const override;
+ CPDF_ShadingObject* AsShading() override;
+ const CPDF_ShadingObject* AsShading() const override;
void CalcBoundingBox();
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_textobject.h b/core/fpdfapi/fpdf_page/include/cpdf_textobject.h
index c47180ef6b..9438811006 100644
--- a/core/fpdfapi/fpdf_page/include/cpdf_textobject.h
+++ b/core/fpdfapi/fpdf_page/include/cpdf_textobject.h
@@ -22,30 +22,30 @@ class CPDF_TextObject : public CPDF_PageObject {
CPDF_TextObject();
~CPDF_TextObject() override;
- // CPDF_PageObject:
+ // CPDF_PageObject
CPDF_TextObject* Clone() const override;
- Type GetType() const override { return TEXT; };
+ Type GetType() const override;
void Transform(const CFX_Matrix& matrix) override;
- bool IsText() const override { return true; };
- CPDF_TextObject* AsText() override { return this; };
- const CPDF_TextObject* AsText() const override { return this; };
+ bool IsText() const override;
+ CPDF_TextObject* AsText() override;
+ const CPDF_TextObject* AsText() const override;
- int CountItems() const { return m_nChars; }
+ int CountItems() const;
void GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const;
int CountChars() const;
void GetCharInfo(int index, uint32_t& charcode, FX_FLOAT& kerning) const;
void GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const;
FX_FLOAT GetCharWidth(uint32_t charcode) const;
- FX_FLOAT GetPosX() const { return m_PosX; }
- FX_FLOAT GetPosY() const { return m_PosY; }
+ FX_FLOAT GetPosX() const;
+ FX_FLOAT GetPosY() const;
void GetTextMatrix(CFX_Matrix* pMatrix) const;
- CPDF_Font* GetFont() const { return m_TextState.GetFont(); }
- FX_FLOAT GetFontSize() const { return m_TextState.GetFontSize(); }
+ CPDF_Font* GetFont() const;
+ FX_FLOAT GetFontSize() const;
void SetText(const CFX_ByteString& text);
void SetPosition(FX_FLOAT x, FX_FLOAT y);
- void RecalcPositionData() { CalcPositionData(nullptr, nullptr, 1); }
+ void RecalcPositionData();
protected:
friend class CPDF_RenderStatus;
diff --git a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp
index 9018f06399..6f8f9ee1a6 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp
@@ -835,6 +835,10 @@ IPDF_DataAvail::DocLinearizationStatus CPDF_DataAvail::IsLinearizedPDF() {
return NotLinearized;
}
+FX_BOOL CPDF_DataAvail::IsLinearized() {
+ return m_bLinearized;
+}
+
FX_BOOL CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, uint32_t dwLen) {
if (m_pLinearized)
return m_bLinearized;
@@ -969,7 +973,7 @@ int32_t CPDF_DataAvail::CheckCrossRefStream(
return 0;
}
-inline void CPDF_DataAvail::SetStartOffset(FX_FILESIZE dwOffset) {
+void CPDF_DataAvail::SetStartOffset(FX_FILESIZE dwOffset) {
m_Pos = dwOffset;
}
diff --git a/core/fpdfapi/fpdf_parser/cpdf_data_avail.h b/core/fpdfapi/fpdf_parser/cpdf_data_avail.h
index f7da8f0d22..553489a267 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_data_avail.h
+++ b/core/fpdfapi/fpdf_parser/cpdf_data_avail.h
@@ -56,13 +56,13 @@ class CPDF_DataAvail final : public IPDF_DataAvail {
FX_BOOL bSupportHintTable);
~CPDF_DataAvail() override;
- // IPDF_DataAvail:
+ // IPDF_DataAvail
DocAvailStatus IsDocAvail(DownloadHints* pHints) override;
void SetDocument(CPDF_Document* pDoc) override;
DocAvailStatus IsPageAvail(int iPage, DownloadHints* pHints) override;
DocFormStatus IsFormAvail(DownloadHints* pHints) override;
DocLinearizationStatus IsLinearizedPDF() override;
- FX_BOOL IsLinearized() override { return m_bLinearized; }
+ FX_BOOL IsLinearized() override;
void GetLinearizedMainXRefInfo(FX_FILESIZE* pPos, uint32_t* pSize) override;
int GetPageCount() const;
diff --git a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
index 3e08ead9ff..8f810aa888 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
@@ -23,6 +23,13 @@ bool CanReadFromBitStream(const CFX_BitStream* hStream,
} // namespace
+CPDF_HintTables::CPDF_HintTables(CPDF_DataAvail* pDataAvail,
+ CPDF_Dictionary* pLinearized)
+ : m_pDataAvail(pDataAvail),
+ m_pLinearizedDict(pLinearized),
+ m_nFirstPageSharedObjs(0),
+ m_szFirstPageObjOffset(0) {}
+
CPDF_HintTables::~CPDF_HintTables() {
m_dwDeltaNObjsArray.RemoveAll();
m_dwNSharedObjsArray.RemoveAll();
diff --git a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.h b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.h
index 33b6b39323..4436339e82 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.h
+++ b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.h
@@ -20,11 +20,7 @@ class CPDF_Stream;
class CPDF_HintTables {
public:
- CPDF_HintTables(CPDF_DataAvail* pDataAvail, CPDF_Dictionary* pLinearized)
- : m_pDataAvail(pDataAvail),
- m_pLinearizedDict(pLinearized),
- m_nFirstPageSharedObjs(0),
- m_szFirstPageObjOffset(0) {}
+ CPDF_HintTables(CPDF_DataAvail* pDataAvail, CPDF_Dictionary* pLinearized);
~CPDF_HintTables();
FX_BOOL GetPagePos(int index,
diff --git a/core/fpdfapi/fpdf_render/cpdf_pagerendercache.h b/core/fpdfapi/fpdf_render/cpdf_pagerendercache.h
index df0d73ac64..d68856b12b 100644
--- a/core/fpdfapi/fpdf_render/cpdf_pagerendercache.h
+++ b/core/fpdfapi/fpdf_render/cpdf_pagerendercache.h
@@ -21,12 +21,7 @@ class IFX_Pause;
class CPDF_PageRenderCache {
public:
- explicit CPDF_PageRenderCache(CPDF_Page* pPage)
- : m_pPage(pPage),
- m_pCurImageCacheEntry(nullptr),
- m_nTimeCount(0),
- m_nCacheSize(0),
- m_bCurFindCache(FALSE) {}
+ explicit CPDF_PageRenderCache(CPDF_Page* pPage);
~CPDF_PageRenderCache();
uint32_t EstimateSize();
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp b/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp
index 07fa2e7b82..055e2f03cb 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_cache.cpp
@@ -24,6 +24,13 @@ static int compare(const void* data1, const void* data2) {
}
} // extern "C"
+CPDF_PageRenderCache::CPDF_PageRenderCache(CPDF_Page* pPage)
+ : m_pPage(pPage),
+ m_pCurImageCacheEntry(nullptr),
+ m_nTimeCount(0),
+ m_nCacheSize(0),
+ m_bCurFindCache(FALSE) {}
+
CPDF_PageRenderCache::~CPDF_PageRenderCache() {
for (const auto& it : m_ImageCache)
delete it.second;
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
index 16a06f8f3b..272c779fe8 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -179,6 +179,11 @@ FXDIB_Format CPDF_DIBTransferFunc::GetDestFormat() {
return (m_pSrc->HasAlpha()) ? FXDIB_Argb : FXDIB_Rgb;
#endif
}
+
+FX_ARGB* CPDF_DIBTransferFunc::GetDestPalette() {
+ return nullptr;
+}
+
CPDF_DIBTransferFunc::CPDF_DIBTransferFunc(
const CPDF_TransferFunc* pTransferFunc) {
m_RampR = pTransferFunc->m_Samples;
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
index 9e3a6c6587..5b0ad96aee 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_text.cpp
@@ -45,12 +45,15 @@ void CPDF_UniqueKeyGen::Generate(int count, ...) {
} // namespace
+CPDF_Type3Cache::CPDF_Type3Cache(CPDF_Type3Font* pFont) : m_pFont(pFont) {}
+
CPDF_Type3Cache::~CPDF_Type3Cache() {
for (const auto& pair : m_SizeMap) {
delete pair.second;
}
m_SizeMap.clear();
}
+
CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(uint32_t charcode,
const CFX_Matrix* pMatrix,
FX_FLOAT retinaScaleX,
@@ -77,10 +80,15 @@ CFX_GlyphBitmap* CPDF_Type3Cache::LoadGlyph(uint32_t charcode,
pSizeCache->m_GlyphMap[charcode] = pGlyphBitmap;
return pGlyphBitmap;
}
+
+CPDF_Type3Glyphs::CPDF_Type3Glyphs()
+ : m_TopBlueCount(0), m_BottomBlueCount(0) {}
+
CPDF_Type3Glyphs::~CPDF_Type3Glyphs() {
for (const auto& pair : m_GlyphMap)
delete pair.second;
}
+
static int _AdjustBlue(FX_FLOAT pos, int& count, int blues[]) {
FX_FLOAT min_distance = 1000000.0f * 1.0f;
int closest_pos = -1;
diff --git a/core/fpdfapi/fpdf_render/render_int.h b/core/fpdfapi/fpdf_render/render_int.h
index f373b9371a..67eae91f59 100644
--- a/core/fpdfapi/fpdf_render/render_int.h
+++ b/core/fpdfapi/fpdf_render/render_int.h
@@ -50,8 +50,9 @@ FX_BOOL IsAvailableMatrix(const CFX_Matrix& matrix);
class CPDF_Type3Glyphs {
public:
- CPDF_Type3Glyphs() : m_TopBlueCount(0), m_BottomBlueCount(0) {}
+ CPDF_Type3Glyphs();
~CPDF_Type3Glyphs();
+
void AdjustBlue(FX_FLOAT top,
FX_FLOAT bottom,
int& top_line,
@@ -63,9 +64,10 @@ class CPDF_Type3Glyphs {
int m_TopBlueCount;
int m_BottomBlueCount;
};
+
class CPDF_Type3Cache {
public:
- explicit CPDF_Type3Cache(CPDF_Type3Font* pFont) : m_pFont(pFont) {}
+ explicit CPDF_Type3Cache(CPDF_Type3Font* pFont);
~CPDF_Type3Cache();
CFX_GlyphBitmap* LoadGlyph(uint32_t charcode,
@@ -605,12 +607,12 @@ class CPDF_DIBSource : public CFX_DIBSource {
#define FPDF_HUGE_IMAGE_SIZE 60000000
class CPDF_DIBTransferFunc : public CFX_FilteredDIB {
public:
- CPDF_DIBTransferFunc(const CPDF_TransferFunc* pTransferFunc);
+ explicit CPDF_DIBTransferFunc(const CPDF_TransferFunc* pTransferFunc);
~CPDF_DIBTransferFunc() override;
// CFX_FilteredDIB
FXDIB_Format GetDestFormat() override;
- FX_ARGB* GetDestPalette() override { return nullptr; }
+ FX_ARGB* GetDestPalette() override;
void TranslateScanline(uint8_t* dest_buf,
const uint8_t* src_buf) const override;
void TranslateDownSamples(uint8_t* dest_buf,