summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authornpm <npm@chromium.org>2016-09-08 14:21:51 -0700
committerCommit bot <commit-bot@chromium.org>2016-09-08 14:21:51 -0700
commit0ca160fbf31a7408df282823f7a3d4cbb5f386a1 (patch)
treeb590926b9beb78f7d5504cbdfc5b3ba33ff1bfa0 /core/fpdfapi
parentc2d0e29cd8fa24c9af0cc4f2a15f90096a5ca8e2 (diff)
downloadpdfium-0ca160fbf31a7408df282823f7a3d4cbb5f386a1.tar.xz
Delete unused methods in CPDF_Document
Review-Url: https://codereview.chromium.org/2323933002
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_document.cpp379
-rw-r--r--core/fpdfapi/fpdf_parser/include/cpdf_document.h17
2 files changed, 0 insertions, 396 deletions
diff --git a/core/fpdfapi/fpdf_parser/cpdf_document.cpp b/core/fpdfapi/fpdf_parser/cpdf_document.cpp
index 89b41d5820..8910fa1205 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_document.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_document.cpp
@@ -220,127 +220,6 @@ CFX_ByteString FPDF_GetPSNameFromTT(HDC hDC) {
}
#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
-struct FX_LANG2CS {
- uint32_t uLang;
- uint8_t uCharset;
-};
-const FX_LANG2CS gs_FXLang2CharsetTable[] = {
- {3109, 0}, {3121, 178}, {3129, 162}, {3139, 204}, {3141, 204},
- {3166, 0}, {3184, 238}, {3197, 0}, {3201, 0}, {3239, 161},
- {3241, 0}, {3246, 0}, {3247, 186}, {3248, 0}, {3259, 178},
- {3267, 0}, {3273, 0}, {3276, 0}, {3301, 0}, {3310, 1},
- {3325, 177}, {3329, 1}, {3338, 238}, {3341, 238}, {3345, 1},
- {3355, 0}, {3370, 0}, {3371, 0}, {3383, 128}, {3424, 204},
- {3427, 1}, {3428, 129}, {3436, 178}, {3464, 186}, {3466, 186},
- {3486, 204}, {3487, 0}, {3493, 1}, {3494, 0}, {3508, 0},
- {3518, 0}, {3520, 0}, {3569, 1}, {3580, 238}, {3588, 0},
- {3645, 238}, {3651, 204}, {3672, 238}, {3673, 238}, {3678, 238},
- {3679, 238}, {3683, 0}, {3684, 0}, {3693, 1}, {3697, 1},
- {3700, 222}, {3710, 162}, {3734, 204}, {3741, 178}, {3749, 162},
- {3763, 163}, {3886, 134}, {105943, 0}, {106375, 1}, {3923451837, 134},
- {3923451838, 136},
-};
-
-uint32_t FX_GetLangHashCode(const FX_CHAR* pStr) {
- ASSERT(pStr);
- int32_t iLength = FXSYS_strlen(pStr);
- const FX_CHAR* pStrEnd = pStr + iLength;
- uint32_t uHashCode = 0;
- while (pStr < pStrEnd)
- uHashCode = 31 * uHashCode + tolower(*pStr++);
- return uHashCode;
-}
-
-uint8_t FX_GetCsFromLangCode(uint32_t uCode) {
- int32_t iStart = 0;
- int32_t iEnd = FX_ArraySize(gs_FXLang2CharsetTable) - 1;
- while (iStart <= iEnd) {
- int32_t iMid = (iStart + iEnd) / 2;
- const FX_LANG2CS& charset = gs_FXLang2CharsetTable[iMid];
- if (uCode == charset.uLang)
- return charset.uCharset;
-
- if (uCode < charset.uLang)
- iEnd = iMid - 1;
- else
- iStart = iMid + 1;
- }
- return FXFONT_ANSI_CHARSET;
-}
-
-uint8_t FX_GetCharsetFromLang(const FX_CHAR* pLang, int32_t iLength) {
- ASSERT(pLang);
- if (iLength < 0)
- iLength = FXSYS_strlen(pLang);
-
- uint32_t uHash = FX_GetLangHashCode(pLang);
- return FX_GetCsFromLangCode(uHash);
-}
-
-void CFString2CFXByteString(CFStringRef src, CFX_ByteString& dest) {
- SInt32 len = CFStringGetLength(src);
- CFRange range = CFRangeMake(0, len);
- CFIndex used = 0;
- UInt8* pBuffer = (UInt8*)calloc(len + 1, sizeof(UInt8));
- CFStringGetBytes(src, range, kCFStringEncodingASCII, 0, false, pBuffer, len,
- &used);
- dest = (FX_CHAR*)pBuffer;
- free(pBuffer);
-}
-
-bool HasCharSet(CFArrayRef languages, const std::vector<uint8_t>& charsets) {
- for (int i = 0; i < CFArrayGetCount(languages); ++i) {
- CFStringRef language = (CFStringRef)CFArrayGetValueAtIndex(languages, i);
- uint8_t charset = FX_GetCharsetFromLang(
- CFStringGetCStringPtr(language, kCFStringEncodingMacRoman), -1);
- if (pdfium::ContainsValue(charsets, charset))
- return true;
- }
- return false;
-}
-
-void FX_GetCharWidth(CTFontRef font, UniChar start, UniChar end, int* width) {
- CGFloat size = CTFontGetSize(font);
- for (; start <= end; ++start) {
- CGGlyph pGlyph = 0;
- CFIndex count = 1;
- CTFontGetGlyphsForCharacters(font, &start, &pGlyph, count);
- CGSize advances;
- CTFontGetAdvancesForGlyphs(font, kCTFontDefaultOrientation, &pGlyph,
- &advances, 1);
- *width = (int)(advances.width / size * 1000);
- width++;
- }
-}
-
-void InsertWidthArray(CTFontRef font,
- int start,
- int end,
- CPDF_Array* pWidthArray) {
- int size = end - start + 1;
- int* widths = FX_Alloc(int, size);
- FX_GetCharWidth(font, start, end, widths);
- int i;
- for (i = 1; i < size; i++) {
- if (widths[i] != *widths)
- break;
- }
- if (i == size) {
- int first = pWidthArray->GetIntegerAt(pWidthArray->GetCount() - 1);
- pWidthArray->AddInteger(first + size - 1);
- pWidthArray->AddInteger(*widths);
- } else {
- CPDF_Array* pWidthArray1 = new CPDF_Array;
- pWidthArray->Add(pWidthArray1);
- for (i = 0; i < size; i++) {
- pWidthArray1->AddInteger(widths[i]);
- }
- }
- FX_Free(widths);
-}
-#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
-
void InsertWidthArray1(CFX_Font* pFont,
CFX_UnicodeEncoding* pEncoding,
FX_WCHAR start,
@@ -520,10 +399,6 @@ void CPDF_Document::LoadDocInternal() {
CPDF_Object* pInfoObj = GetOrParseIndirectObject(m_pParser->GetInfoObjNum());
if (pInfoObj)
m_pInfoDict = pInfoObj->GetDict();
- if (CPDF_Array* pIDArray = m_pParser->GetIDArray()) {
- m_ID1 = pIDArray->GetStringAt(0);
- m_ID2 = pIDArray->GetStringAt(1);
- }
}
void CPDF_Document::LoadDoc() {
@@ -736,20 +611,6 @@ uint32_t CPDF_Document::GetUserPermissions() const {
return m_pParser->GetPermissions();
}
-FX_BOOL CPDF_Document::IsFormStream(uint32_t objnum, FX_BOOL& bForm) const {
- CPDF_Object* pObj = GetIndirectObject(objnum);
- if (pObj) {
- CPDF_Stream* pStream = pObj->AsStream();
- bForm = pStream && pStream->GetDict()->GetStringBy("Subtype") == "Form";
- return TRUE;
- }
- if (!m_pParser) {
- bForm = FALSE;
- return TRUE;
- }
- return m_pParser->IsFormStream(objnum, bForm);
-}
-
CPDF_Font* CPDF_Document::LoadFont(CPDF_Dictionary* pFontDict) {
ASSERT(pFontDict);
return m_pDocPage->GetFont(pFontDict, FALSE);
@@ -782,24 +643,6 @@ CPDF_Image* CPDF_Document::LoadImageF(CPDF_Object* pObj) {
return m_pDocPage->GetImage(pObj);
}
-void CPDF_Document::RemoveColorSpaceFromPageData(CPDF_Object* pCSObj) {
- GetPageData()->ReleaseColorSpace(pCSObj);
-}
-
-void CPDF_Document::ClearPageData() {
- GetPageData()->Clear(FALSE);
-}
-
-void CPDF_Document::ClearRenderData() {
- m_pDocRender->Clear(FALSE);
-}
-
-void CPDF_Document::ClearRenderFont() {
- CFX_FontCache* pCache = m_pDocRender->GetFontCache();
- if (pCache)
- pCache->FreeCache(FALSE);
-}
-
void CPDF_Document::CreateNewDoc() {
ASSERT(!m_pRootDict && !m_pInfoDict);
m_pRootDict = new CPDF_Dictionary;
@@ -1236,225 +1079,3 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont,
return LoadFont(pBaseDict);
}
#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
-
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
-CPDF_Font* CPDF_Document::AddMacFont(CTFontRef pFont,
- FX_BOOL bVert,
- FX_BOOL bTranslateName) {
- CTFontRef font = (CTFontRef)pFont;
- CTFontDescriptorRef descriptor = CTFontCopyFontDescriptor(font);
- if (!descriptor)
- return nullptr;
-
- CFArrayRef languages = (CFArrayRef)CTFontDescriptorCopyAttribute(
- descriptor, kCTFontLanguagesAttribute);
- if (!languages) {
- CFRelease(descriptor);
- return nullptr;
- }
-
- bool bCJK =
- HasCharSet(languages, {FXFONT_CHINESEBIG5_CHARSET, FXFONT_GB2312_CHARSET,
- FXFONT_HANGEUL_CHARSET, FXFONT_SHIFTJIS_CHARSET});
- CFRelease(descriptor);
- CFDictionaryRef traits = (CFDictionaryRef)CTFontCopyTraits(font);
- if (!traits) {
- CFRelease(languages);
- return nullptr;
- }
-
- CFNumberRef sybolicTrait =
- (CFNumberRef)CFDictionaryGetValue(traits, kCTFontSymbolicTrait);
- CTFontSymbolicTraits trait = 0;
- CFNumberGetValue(sybolicTrait, kCFNumberSInt32Type, &trait);
- int flags = 0;
- if (trait & kCTFontItalicTrait)
- flags |= PDFFONT_ITALIC;
- if (trait & kCTFontMonoSpaceTrait)
- flags |= PDFFONT_FIXEDPITCH;
- if (trait & kCTFontModernSerifsClass)
- flags |= PDFFONT_SERIF;
- if (trait & kCTFontScriptsClass)
- flags |= PDFFONT_SCRIPT;
-
- CFNumberRef weightTrait =
- (CFNumberRef)CFDictionaryGetValue(traits, kCTFontWeightTrait);
- Float32 weight = 0;
- CFNumberGetValue(weightTrait, kCFNumberFloat32Type, &weight);
- int italicangle = CTFontGetSlantAngle(font);
- int ascend = CTFontGetAscent(font);
- int descend = CTFontGetDescent(font);
- int capheight = CTFontGetCapHeight(font);
- CGRect box = CTFontGetBoundingBox(font);
- int bbox[4];
- bbox[0] = box.origin.x;
- bbox[1] = box.origin.y;
- bbox[2] = box.origin.x + box.size.width;
- bbox[3] = box.origin.y + box.size.height;
- CFX_ByteString basefont;
- if (bTranslateName && bCJK) {
- CFStringRef postName = CTFontCopyPostScriptName(font);
- CFString2CFXByteString(postName, basefont);
- CFRelease(postName);
- }
- if (basefont.IsEmpty()) {
- CFStringRef fullName = CTFontCopyFullName(font);
- CFString2CFXByteString(fullName, basefont);
- CFRelease(fullName);
- }
- basefont.Replace(" ", "");
- CPDF_Dictionary* pBaseDict = new CPDF_Dictionary;
- CPDF_Dictionary* pFontDict = pBaseDict;
- if (!bCJK) {
- if (HasCharSet(languages, {FXFONT_ANSI_CHARSET, FXFONT_DEFAULT_CHARSET,
- FXFONT_SYMBOL_CHARSET})) {
- if (HasCharSet(languages, {FXFONT_SYMBOL_CHARSET})) {
- flags |= PDFFONT_SYMBOLIC;
- } else {
- flags |= PDFFONT_NONSYMBOLIC;
- }
- pBaseDict->SetAtName("Encoding", "WinAnsiEncoding");
- } else {
- flags |= PDFFONT_NONSYMBOLIC;
- size_t i;
- for (i = 0; i < FX_ArraySize(g_FX_CharsetUnicodes); ++i) {
- if (HasCharSet(languages, {g_FX_CharsetUnicodes[i].m_Charset}))
- break;
- }
- if (i < FX_ArraySize(g_FX_CharsetUnicodes)) {
- CPDF_Dictionary* pEncoding = new CPDF_Dictionary;
- pEncoding->SetAtName("BaseEncoding", "WinAnsiEncoding");
- CPDF_Array* pArray = new CPDF_Array;
- pArray->AddInteger(128);
- const uint16_t* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes;
- for (int j = 0; j < 128; j++) {
- CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]);
- pArray->AddName(name.IsEmpty() ? ".notdef" : name);
- }
- pEncoding->SetAt("Differences", pArray);
- AddIndirectObject(pEncoding);
- pBaseDict->SetAtReference("Encoding", this, pEncoding);
- }
- }
- if (weight > 0.0 && trait & kCTFontItalicTrait)
- basefont += ",BoldItalic";
- else if (weight > 0.0)
- basefont += ",Bold";
- else if (trait & kCTFontItalicTrait)
- basefont += ",Italic";
-
- pBaseDict->SetAtName("Subtype", "TrueType");
- pBaseDict->SetAtName("BaseFont", basefont);
- pBaseDict->SetAtNumber("FirstChar", 32);
- pBaseDict->SetAtNumber("LastChar", 255);
- int char_widths[224];
- FX_GetCharWidth(font, 32, 255, char_widths);
- CPDF_Array* pWidths = new CPDF_Array;
- for (int i = 0; i < 224; i++)
- pWidths->AddInteger(char_widths[i]);
- pBaseDict->SetAt("Widths", pWidths);
- } else {
- flags |= PDFFONT_NONSYMBOLIC;
- CFX_ByteString cmap;
- CFX_ByteString ordering;
- int supplement;
- bool bFound = false;
- CPDF_Array* pWidthArray = new CPDF_Array;
- if (HasCharSet(languages, {FXFONT_CHINESEBIG5_CHARSET})) {
- cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H";
- ordering = "CNS1";
- supplement = 4;
- pWidthArray->AddInteger(1);
- InsertWidthArray(font, 0x20, 0x7e, pWidthArray);
- bFound = true;
- }
- if (!bFound && HasCharSet(languages, {FXFONT_GB2312_CHARSET})) {
- cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H";
- ordering = "GB1", supplement = 2;
- pWidthArray->AddInteger(7716);
- InsertWidthArray(font, 0x20, 0x20, pWidthArray);
- pWidthArray->AddInteger(814);
- InsertWidthArray(font, 0x21, 0x7e, pWidthArray);
- bFound = true;
- }
- if (!bFound && HasCharSet(languages, {FXFONT_HANGEUL_CHARSET})) {
- cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H";
- ordering = "Korea1";
- supplement = 2;
- pWidthArray->AddInteger(1);
- InsertWidthArray(font, 0x20, 0x7e, pWidthArray);
- bFound = true;
- }
- if (!bFound && HasCharSet(languages, {FXFONT_SHIFTJIS_CHARSET})) {
- cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H";
- ordering = "Japan1";
- supplement = 5;
- pWidthArray->AddInteger(231);
- InsertWidthArray(font, 0x20, 0x7d, pWidthArray);
- pWidthArray->AddInteger(326);
- InsertWidthArray(font, 0xa0, 0xa0, pWidthArray);
- pWidthArray->AddInteger(327);
- InsertWidthArray(font, 0xa1, 0xdf, pWidthArray);
- pWidthArray->AddInteger(631);
- InsertWidthArray(font, 0x7e, 0x7e, pWidthArray);
- }
- pBaseDict->SetAtName("Subtype", "Type0");
- pBaseDict->SetAtName("BaseFont", basefont);
- pBaseDict->SetAtName("Encoding", cmap);
-
- pFontDict = new CPDF_Dictionary;
- pFontDict->SetAt("W", pWidthArray);
- pFontDict->SetAtName("Type", "Font");
- pFontDict->SetAtName("Subtype", "CIDFontType2");
- pFontDict->SetAtName("BaseFont", basefont);
- CPDF_Dictionary* pCIDSysInfo = new CPDF_Dictionary;
- pCIDSysInfo->SetAtString("Registry", "Adobe");
- pCIDSysInfo->SetAtString("Ordering", ordering);
- pCIDSysInfo->SetAtInteger("Supplement", supplement);
- pFontDict->SetAt("CIDSystemInfo", pCIDSysInfo);
- CPDF_Array* pArray = new CPDF_Array;
- pBaseDict->SetAt("DescendantFonts", pArray);
- AddIndirectObject(pFontDict);
- pArray->AddReference(this, pFontDict);
- }
- AddIndirectObject(pBaseDict);
- CPDF_Dictionary* pFontDesc = new CPDF_Dictionary;
- pFontDesc->SetAtName("Type", "FontDescriptor");
- pFontDesc->SetAtName("FontName", basefont);
- pFontDesc->SetAtInteger("Flags", flags);
- CPDF_Array* pBBox = new CPDF_Array;
- for (int i = 0; i < 4; i++)
- pBBox->AddInteger(bbox[i]);
-
- pFontDesc->SetAt("FontBBox", pBBox);
- pFontDesc->SetAtInteger("ItalicAngle", italicangle);
- pFontDesc->SetAtInteger("Ascent", ascend);
- pFontDesc->SetAtInteger("Descent", descend);
- pFontDesc->SetAtInteger("CapHeight", capheight);
- CGFloat fStemV = 0;
- int16_t min_width = SHRT_MAX;
-
- static const UniChar stem_chars[] = {'i', 'I', '!', '1'};
- CGGlyph glyphs[FX_ArraySize(stem_chars)];
- CGRect boundingRects[FX_ArraySize(stem_chars)];
-
- const size_t count = FX_ArraySize(stem_chars);
- if (CTFontGetGlyphsForCharacters(font, stem_chars, glyphs, count)) {
- CTFontGetBoundingRectsForGlyphs(font, kCTFontHorizontalOrientation, glyphs,
- boundingRects, count);
- for (size_t i = 0; i < count; i++) {
- int16_t width = boundingRects[i].size.width;
- if (width > 0 && width < min_width) {
- min_width = width;
- fStemV = min_width;
- }
- }
- }
- pFontDesc->SetAtInteger("StemV", fStemV);
- AddIndirectObject(pFontDesc);
- pFontDict->SetAtReference("FontDescriptor", this, pFontDesc);
- CFRelease(traits);
- CFRelease(languages);
- return LoadFont(pBaseDict);
-}
-#endif // _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_document.h b/core/fpdfapi/fpdf_parser/include/cpdf_document.h
index f3322425ed..2d315e9d5b 100644
--- a/core/fpdfapi/fpdf_parser/include/cpdf_document.h
+++ b/core/fpdfapi/fpdf_parser/include/cpdf_document.h
@@ -47,18 +47,11 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
CPDF_Dictionary* GetRoot() const { return m_pRootDict; }
CPDF_Dictionary* GetInfo() const { return m_pInfoDict; }
- void GetID(CFX_ByteString& id1, CFX_ByteString& id2) const {
- id1 = m_ID1;
- id2 = m_ID2;
- }
-
int GetPageCount() const;
CPDF_Dictionary* GetPage(int iPage);
int GetPageIndex(uint32_t objnum);
uint32_t GetUserPermissions() const;
CPDF_DocPageData* GetPageData() const { return m_pDocPage; }
- void ClearPageData();
- void RemoveColorSpaceFromPageData(CPDF_Object* pObject);
std::unique_ptr<JBig2_DocumentContext>* CodecContext() {
return &m_pCodecContext;
@@ -66,8 +59,6 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
std::unique_ptr<CPDF_LinkList>* LinksContext() { return &m_pLinksContext; }
CPDF_DocRenderData* GetRenderData() const { return m_pDocRender.get(); }
- void ClearRenderData();
- void ClearRenderFont();
FX_BOOL IsFormStream(uint32_t objnum, FX_BOOL& bForm) const;
@@ -102,11 +93,6 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
FX_BOOL bVert,
FX_BOOL bTranslateName = FALSE);
#endif
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
- CPDF_Font* AddMacFont(CTFontRef pFont,
- FX_BOOL bVert,
- FX_BOOL bTranslateName = FALSE);
-#endif
protected:
friend class CPDF_Creator;
@@ -125,14 +111,11 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
uint32_t objnum,
int& index,
int level = 0);
- FX_BOOL CheckOCGVisible(CPDF_Dictionary* pOCG, FX_BOOL bPrinting);
CPDF_Object* ParseIndirectObject(uint32_t objnum) override;
std::unique_ptr<CPDF_Parser> m_pParser;
CPDF_Dictionary* m_pRootDict;
CPDF_Dictionary* m_pInfoDict;
- CFX_ByteString m_ID1;
- CFX_ByteString m_ID2;
bool m_bLinearized;
int m_iFirstPageNo;
uint32_t m_dwFirstPageObjNum;