| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "../../../include/fpdfapi/fpdf_page.h" | 7 #include "../../../include/fpdfapi/fpdf_page.h" |
| 8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
| 9 #include "../fpdf_page/pageint.h" | 9 #include "../fpdf_page/pageint.h" |
| 10 #include <limits.h> | 10 #include <limits.h> |
| 11 CPDF_Document::CPDF_Document() : CPDF_IndirectObjects(NULL) | 11 CPDF_Document::CPDF_Document() : CPDF_IndirectObjects(NULL) |
| 12 { | 12 { |
| 13 m_pRootDict = NULL; | 13 m_pRootDict = NULL; |
| 14 m_pInfoDict = NULL; | 14 m_pInfoDict = NULL; |
| 15 m_bLinearized = FALSE; | 15 m_bLinearized = false; |
| 16 m_dwFirstPageNo = 0; | 16 m_dwFirstPageNo = 0; |
| 17 m_dwFirstPageObjNum = 0; | 17 m_dwFirstPageObjNum = 0; |
| 18 m_pDocPage = CPDF_ModuleMgr::Get()->GetPageModule()->CreateDocData(this); | 18 m_pDocPage = CPDF_ModuleMgr::Get()->GetPageModule()->CreateDocData(this); |
| 19 m_pDocRender = CPDF_ModuleMgr::Get()->GetRenderModule()->CreateDocData(this)
; | 19 m_pDocRender = CPDF_ModuleMgr::Get()->GetRenderModule()->CreateDocData(this)
; |
| 20 } | 20 } |
| 21 void CPDF_Document::CreateNewDoc() | 21 void CPDF_Document::CreateNewDoc() |
| 22 { | 22 { |
| 23 ASSERT(m_pRootDict == NULL && m_pInfoDict == NULL); | 23 ASSERT(m_pRootDict == NULL && m_pInfoDict == NULL); |
| 24 m_pRootDict = new CPDF_Dictionary; | 24 m_pRootDict = new CPDF_Dictionary; |
| 25 m_pRootDict->SetAtName("Type", "Catalog"); | 25 m_pRootDict->SetAtName("Type", "Catalog"); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 pWidthArray->AddInteger(*widths); | 208 pWidthArray->AddInteger(*widths); |
| 209 } else { | 209 } else { |
| 210 CPDF_Array* pWidthArray1 = new CPDF_Array; | 210 CPDF_Array* pWidthArray1 = new CPDF_Array; |
| 211 pWidthArray->Add(pWidthArray1); | 211 pWidthArray->Add(pWidthArray1); |
| 212 for (i = 0; i < size; i ++) { | 212 for (i = 0; i < size; i ++) { |
| 213 pWidthArray1->AddInteger(widths[i]); | 213 pWidthArray1->AddInteger(widths[i]); |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 FX_Free(widths); | 216 FX_Free(widths); |
| 217 } | 217 } |
| 218 CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTW* pLogFont, FX_BOOL bVert, FX_B
OOL bTranslateName) | 218 CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTW* pLogFont, bool bVert, bool bT
ranslateName) |
| 219 { | 219 { |
| 220 LOGFONTA lfa; | 220 LOGFONTA lfa; |
| 221 FXSYS_memcpy(&lfa, pLogFont, (char*)lfa.lfFaceName - (char*)&lfa); | 221 FXSYS_memcpy(&lfa, pLogFont, (char*)lfa.lfFaceName - (char*)&lfa); |
| 222 CFX_ByteString face = CFX_ByteString::FromUnicode(pLogFont->lfFaceName); | 222 CFX_ByteString face = CFX_ByteString::FromUnicode(pLogFont->lfFaceName); |
| 223 if (face.GetLength() >= LF_FACESIZE) { | 223 if (face.GetLength() >= LF_FACESIZE) { |
| 224 return NULL; | 224 return NULL; |
| 225 } | 225 } |
| 226 FXSYS_strcpy(lfa.lfFaceName, face.c_str()); | 226 FXSYS_strcpy(lfa.lfFaceName, face.c_str()); |
| 227 return AddWindowsFont(&lfa, bVert, bTranslateName); | 227 return AddWindowsFont(&lfa, bVert, bTranslateName); |
| 228 } | 228 } |
| 229 extern CFX_ByteString _FPDF_GetNameFromTT(const uint8_t* name_table, FX_DWORD na
me); | 229 extern CFX_ByteString _FPDF_GetNameFromTT(const uint8_t* name_table, FX_DWORD na
me); |
| 230 CFX_ByteString _FPDF_GetPSNameFromTT(HDC hDC) | 230 CFX_ByteString _FPDF_GetPSNameFromTT(HDC hDC) |
| 231 { | 231 { |
| 232 CFX_ByteString result; | 232 CFX_ByteString result; |
| 233 DWORD size = ::GetFontData(hDC, 'eman', 0, NULL, 0); | 233 DWORD size = ::GetFontData(hDC, 'eman', 0, NULL, 0); |
| 234 if (size != GDI_ERROR) { | 234 if (size != GDI_ERROR) { |
| 235 LPBYTE buffer = FX_Alloc(BYTE, size); | 235 LPBYTE buffer = FX_Alloc(BYTE, size); |
| 236 ::GetFontData(hDC, 'eman', 0, buffer, size); | 236 ::GetFontData(hDC, 'eman', 0, buffer, size); |
| 237 result = _FPDF_GetNameFromTT(buffer, 6); | 237 result = _FPDF_GetNameFromTT(buffer, 6); |
| 238 FX_Free(buffer); | 238 FX_Free(buffer); |
| 239 } | 239 } |
| 240 return result; | 240 return result; |
| 241 } | 241 } |
| 242 CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont, FX_BOOL bVert, FX_B
OOL bTranslateName) | 242 CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont, bool bVert, bool bT
ranslateName) |
| 243 { | 243 { |
| 244 pLogFont->lfHeight = -1000; | 244 pLogFont->lfHeight = -1000; |
| 245 pLogFont->lfWidth = 0; | 245 pLogFont->lfWidth = 0; |
| 246 HGDIOBJ hFont = CreateFontIndirectA(pLogFont); | 246 HGDIOBJ hFont = CreateFontIndirectA(pLogFont); |
| 247 HDC hDC = CreateCompatibleDC(NULL); | 247 HDC hDC = CreateCompatibleDC(NULL); |
| 248 hFont = SelectObject(hDC, hFont); | 248 hFont = SelectObject(hDC, hFont); |
| 249 int tm_size = GetOutlineTextMetrics(hDC, 0, NULL); | 249 int tm_size = GetOutlineTextMetrics(hDC, 0, NULL); |
| 250 if (tm_size == 0) { | 250 if (tm_size == 0) { |
| 251 hFont = SelectObject(hDC, hFont); | 251 hFont = SelectObject(hDC, hFont); |
| 252 DeleteObject(hFont); | 252 DeleteObject(hFont); |
| 253 DeleteDC(hDC); | 253 DeleteDC(hDC); |
| 254 return NULL; | 254 return NULL; |
| 255 } | 255 } |
| 256 LPBYTE tm_buf = FX_Alloc(BYTE, tm_size); | 256 LPBYTE tm_buf = FX_Alloc(BYTE, tm_size); |
| 257 OUTLINETEXTMETRIC* ptm = (OUTLINETEXTMETRIC*)tm_buf; | 257 OUTLINETEXTMETRIC* ptm = (OUTLINETEXTMETRIC*)tm_buf; |
| 258 GetOutlineTextMetrics(hDC, tm_size, ptm); | 258 GetOutlineTextMetrics(hDC, tm_size, ptm); |
| 259 int flags = 0, italicangle, ascend, descend, capheight, bbox[4]; | 259 int flags = 0, italicangle, ascend, descend, capheight, bbox[4]; |
| 260 if (pLogFont->lfItalic) { | 260 if (pLogFont->lfItalic) { |
| 261 flags |= PDFFONT_ITALIC; | 261 flags |= PDFFONT_ITALIC; |
| 262 } | 262 } |
| 263 if ((pLogFont->lfPitchAndFamily & 3) == FIXED_PITCH) { | 263 if ((pLogFont->lfPitchAndFamily & 3) == FIXED_PITCH) { |
| 264 flags |= PDFFONT_FIXEDPITCH; | 264 flags |= PDFFONT_FIXEDPITCH; |
| 265 } | 265 } |
| 266 if ((pLogFont->lfPitchAndFamily & 0xf8) == FF_ROMAN) { | 266 if ((pLogFont->lfPitchAndFamily & 0xf8) == FF_ROMAN) { |
| 267 flags |= PDFFONT_SERIF; | 267 flags |= PDFFONT_SERIF; |
| 268 } | 268 } |
| 269 if ((pLogFont->lfPitchAndFamily & 0xf8) == FF_SCRIPT) { | 269 if ((pLogFont->lfPitchAndFamily & 0xf8) == FF_SCRIPT) { |
| 270 flags |= PDFFONT_SCRIPT; | 270 flags |= PDFFONT_SCRIPT; |
| 271 } | 271 } |
| 272 FX_BOOL bCJK = pLogFont->lfCharSet == CHINESEBIG5_CHARSET || pLogFont->lfCha
rSet == GB2312_CHARSET || | 272 bool bCJK = pLogFont->lfCharSet == CHINESEBIG5_CHARSET || pLogFont->lfCharSe
t == GB2312_CHARSET || |
| 273 pLogFont->lfCharSet == HANGEUL_CHARSET || pLogFont->lfCharSet
== SHIFTJIS_CHARSET; | 273 pLogFont->lfCharSet == HANGEUL_CHARSET || pLogFont->lfCharSet
== SHIFTJIS_CHARSET; |
| 274 CFX_ByteString basefont; | 274 CFX_ByteString basefont; |
| 275 if (bTranslateName && bCJK) { | 275 if (bTranslateName && bCJK) { |
| 276 basefont = _FPDF_GetPSNameFromTT(hDC); | 276 basefont = _FPDF_GetPSNameFromTT(hDC); |
| 277 } | 277 } |
| 278 if (basefont.IsEmpty()) { | 278 if (basefont.IsEmpty()) { |
| 279 basefont = pLogFont->lfFaceName; | 279 basefont = pLogFont->lfFaceName; |
| 280 } | 280 } |
| 281 italicangle = ptm->otmItalicAngle / 10; | 281 italicangle = ptm->otmItalicAngle / 10; |
| 282 ascend = ptm->otmrcFontBox.top; | 282 ascend = ptm->otmrcFontBox.top; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 static void _CFString2CFXByteString(CFStringRef src, CFX_ByteString &dest) | 541 static void _CFString2CFXByteString(CFStringRef src, CFX_ByteString &dest) |
| 542 { | 542 { |
| 543 SInt32 len = CFStringGetLength(src); | 543 SInt32 len = CFStringGetLength(src); |
| 544 CFRange range = CFRangeMake(0, len); | 544 CFRange range = CFRangeMake(0, len); |
| 545 CFIndex used = 0; | 545 CFIndex used = 0; |
| 546 UInt8* pBuffer = (UInt8*)calloc(len+1, sizeof(UInt8)); | 546 UInt8* pBuffer = (UInt8*)calloc(len+1, sizeof(UInt8)); |
| 547 CFStringGetBytes(src, range, kCFStringEncodingASCII, 0, false, pBuffer, len,
&used); | 547 CFStringGetBytes(src, range, kCFStringEncodingASCII, 0, false, pBuffer, len,
&used); |
| 548 dest = (FX_CHAR*)pBuffer; | 548 dest = (FX_CHAR*)pBuffer; |
| 549 free(pBuffer); | 549 free(pBuffer); |
| 550 } | 550 } |
| 551 FX_BOOL IsHasCharSet(CFArrayRef languages, const CFX_DWordArray &charSets) | 551 bool IsHasCharSet(CFArrayRef languages, const CFX_DWordArray &charSets) |
| 552 { | 552 { |
| 553 int iCount = charSets.GetSize(); | 553 int iCount = charSets.GetSize(); |
| 554 for (int i = 0; i < CFArrayGetCount(languages); ++i) { | 554 for (int i = 0; i < CFArrayGetCount(languages); ++i) { |
| 555 CFStringRef language = (CFStringRef)CFArrayGetValueAtIndex(languages, i)
; | 555 CFStringRef language = (CFStringRef)CFArrayGetValueAtIndex(languages, i)
; |
| 556 FX_DWORD CharSet = FX_GetCharsetFromLang(CFStringGetCStringPtr(language,
kCFStringEncodingMacRoman), -1); | 556 FX_DWORD CharSet = FX_GetCharsetFromLang(CFStringGetCStringPtr(language,
kCFStringEncodingMacRoman), -1); |
| 557 for (int j = 0; j < iCount; ++j) { | 557 for (int j = 0; j < iCount; ++j) { |
| 558 if (CharSet == charSets[j]) { | 558 if (CharSet == charSets[j]) { |
| 559 return TRUE; | 559 return true; |
| 560 } | 560 } |
| 561 } | 561 } |
| 562 } | 562 } |
| 563 return FALSE; | 563 return false; |
| 564 } | 564 } |
| 565 void FX_GetCharWidth(CTFontRef font, UniChar start, UniChar end, int* width) | 565 void FX_GetCharWidth(CTFontRef font, UniChar start, UniChar end, int* width) |
| 566 { | 566 { |
| 567 CGFloat size = CTFontGetSize(font); | 567 CGFloat size = CTFontGetSize(font); |
| 568 for (; start <= end; ++start) { | 568 for (; start <= end; ++start) { |
| 569 CGGlyph pGlyph = 0; | 569 CGGlyph pGlyph = 0; |
| 570 CFIndex count = 1; | 570 CFIndex count = 1; |
| 571 CTFontGetGlyphsForCharacters(font, &start, &pGlyph, count); | 571 CTFontGetGlyphsForCharacters(font, &start, &pGlyph, count); |
| 572 CGSize advances; | 572 CGSize advances; |
| 573 CTFontGetAdvancesForGlyphs(font, kCTFontDefaultOrientation, &pGlyph, &ad
vances, 1); | 573 CTFontGetAdvancesForGlyphs(font, kCTFontDefaultOrientation, &pGlyph, &ad
vances, 1); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 591 pWidthArray->AddInteger(*widths); | 591 pWidthArray->AddInteger(*widths); |
| 592 } else { | 592 } else { |
| 593 CPDF_Array* pWidthArray1 = new CPDF_Array; | 593 CPDF_Array* pWidthArray1 = new CPDF_Array; |
| 594 pWidthArray->Add(pWidthArray1); | 594 pWidthArray->Add(pWidthArray1); |
| 595 for (i = 0; i < size; i ++) { | 595 for (i = 0; i < size; i ++) { |
| 596 pWidthArray1->AddInteger(widths[i]); | 596 pWidthArray1->AddInteger(widths[i]); |
| 597 } | 597 } |
| 598 } | 598 } |
| 599 FX_Free(widths); | 599 FX_Free(widths); |
| 600 } | 600 } |
| 601 CPDF_Font* CPDF_Document::AddMacFont(CTFontRef pFont, FX_BOOL bVert, FX_BOOL bTr
anslateName) | 601 CPDF_Font* CPDF_Document::AddMacFont(CTFontRef pFont, bool bVert, bool bTranslat
eName) |
| 602 { | 602 { |
| 603 CTFontRef font = (CTFontRef)pFont; | 603 CTFontRef font = (CTFontRef)pFont; |
| 604 CTFontDescriptorRef descriptor = CTFontCopyFontDescriptor(font); | 604 CTFontDescriptorRef descriptor = CTFontCopyFontDescriptor(font); |
| 605 if (descriptor == NULL) { | 605 if (descriptor == NULL) { |
| 606 return NULL; | 606 return NULL; |
| 607 } | 607 } |
| 608 CFX_ByteString basefont; | 608 CFX_ByteString basefont; |
| 609 FX_BOOL bCJK = FALSE; | 609 bool bCJK = false; |
| 610 int flags = 0, italicangle = 0, ascend = 0, descend = 0, capheight = 0, bbox
[4]; | 610 int flags = 0, italicangle = 0, ascend = 0, descend = 0, capheight = 0, bbox
[4]; |
| 611 FXSYS_memset(bbox, 0, sizeof(int) * 4); | 611 FXSYS_memset(bbox, 0, sizeof(int) * 4); |
| 612 CFArrayRef languages = (CFArrayRef)CTFontDescriptorCopyAttribute(descriptor,
kCTFontLanguagesAttribute); | 612 CFArrayRef languages = (CFArrayRef)CTFontDescriptorCopyAttribute(descriptor,
kCTFontLanguagesAttribute); |
| 613 if (languages == NULL) { | 613 if (languages == NULL) { |
| 614 CFRelease(descriptor); | 614 CFRelease(descriptor); |
| 615 return NULL; | 615 return NULL; |
| 616 } | 616 } |
| 617 CFX_DWordArray charSets; | 617 CFX_DWordArray charSets; |
| 618 charSets.Add(FXFONT_CHINESEBIG5_CHARSET); | 618 charSets.Add(FXFONT_CHINESEBIG5_CHARSET); |
| 619 charSets.Add(FXFONT_GB2312_CHARSET); | 619 charSets.Add(FXFONT_GB2312_CHARSET); |
| 620 charSets.Add(FXFONT_HANGEUL_CHARSET); | 620 charSets.Add(FXFONT_HANGEUL_CHARSET); |
| 621 charSets.Add(FXFONT_SHIFTJIS_CHARSET); | 621 charSets.Add(FXFONT_SHIFTJIS_CHARSET); |
| 622 if (IsHasCharSet(languages, charSets)) { | 622 if (IsHasCharSet(languages, charSets)) { |
| 623 bCJK = TRUE; | 623 bCJK = true; |
| 624 } | 624 } |
| 625 CFRelease(descriptor); | 625 CFRelease(descriptor); |
| 626 CFDictionaryRef traits = (CFDictionaryRef)CTFontCopyTraits(font); | 626 CFDictionaryRef traits = (CFDictionaryRef)CTFontCopyTraits(font); |
| 627 if (traits == NULL) { | 627 if (traits == NULL) { |
| 628 CFRelease(languages); | 628 CFRelease(languages); |
| 629 return NULL; | 629 return NULL; |
| 630 } | 630 } |
| 631 CFNumberRef sybolicTrait = (CFNumberRef)CFDictionaryGetValue(traits, kCTFont
SymbolicTrait); | 631 CFNumberRef sybolicTrait = (CFNumberRef)CFDictionaryGetValue(traits, kCTFont
SymbolicTrait); |
| 632 CTFontSymbolicTraits trait = 0; | 632 CTFontSymbolicTraits trait = 0; |
| 633 CFNumberGetValue(sybolicTrait, kCFNumberSInt32Type, &trait); | 633 CFNumberGetValue(sybolicTrait, kCFNumberSInt32Type, &trait); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 pWidths->AddInteger(char_widths[i]); | 729 pWidths->AddInteger(char_widths[i]); |
| 730 } | 730 } |
| 731 pBaseDict->SetAt("Widths", pWidths); | 731 pBaseDict->SetAt("Widths", pWidths); |
| 732 } else { | 732 } else { |
| 733 flags |= PDFFONT_NONSYMBOLIC; | 733 flags |= PDFFONT_NONSYMBOLIC; |
| 734 CPDF_Array* pArray = NULL; | 734 CPDF_Array* pArray = NULL; |
| 735 pFontDict = new CPDF_Dictionary; | 735 pFontDict = new CPDF_Dictionary; |
| 736 CFX_ByteString cmap; | 736 CFX_ByteString cmap; |
| 737 CFX_ByteString ordering; | 737 CFX_ByteString ordering; |
| 738 int supplement; | 738 int supplement; |
| 739 FX_BOOL bFound = FALSE; | 739 bool bFound = false; |
| 740 CPDF_Array* pWidthArray = new CPDF_Array; | 740 CPDF_Array* pWidthArray = new CPDF_Array; |
| 741 charSets.RemoveAll(); | 741 charSets.RemoveAll(); |
| 742 charSets.Add(FXFONT_CHINESEBIG5_CHARSET); | 742 charSets.Add(FXFONT_CHINESEBIG5_CHARSET); |
| 743 if (IsHasCharSet(languages, charSets)) { | 743 if (IsHasCharSet(languages, charSets)) { |
| 744 cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H"; | 744 cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H"; |
| 745 ordering = "CNS1"; | 745 ordering = "CNS1"; |
| 746 supplement = 4; | 746 supplement = 4; |
| 747 pWidthArray->AddInteger(1); | 747 pWidthArray->AddInteger(1); |
| 748 _InsertWidthArray(font, 0x20, 0x7e, pWidthArray); | 748 _InsertWidthArray(font, 0x20, 0x7e, pWidthArray); |
| 749 bFound = TRUE; | 749 bFound = true; |
| 750 } | 750 } |
| 751 charSets.RemoveAll(); | 751 charSets.RemoveAll(); |
| 752 charSets.Add(FXFONT_GB2312_CHARSET); | 752 charSets.Add(FXFONT_GB2312_CHARSET); |
| 753 if (!bFound && IsHasCharSet(languages, charSets)) { | 753 if (!bFound && IsHasCharSet(languages, charSets)) { |
| 754 cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H"; | 754 cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H"; |
| 755 ordering = "GB1", supplement = 2; | 755 ordering = "GB1", supplement = 2; |
| 756 pWidthArray->AddInteger(7716); | 756 pWidthArray->AddInteger(7716); |
| 757 _InsertWidthArray(font, 0x20, 0x20, pWidthArray); | 757 _InsertWidthArray(font, 0x20, 0x20, pWidthArray); |
| 758 pWidthArray->AddInteger(814); | 758 pWidthArray->AddInteger(814); |
| 759 _InsertWidthArray(font, 0x21, 0x7e, pWidthArray); | 759 _InsertWidthArray(font, 0x21, 0x7e, pWidthArray); |
| 760 bFound = TRUE; | 760 bFound = true; |
| 761 } | 761 } |
| 762 charSets.RemoveAll(); | 762 charSets.RemoveAll(); |
| 763 charSets.Add(FXFONT_HANGEUL_CHARSET); | 763 charSets.Add(FXFONT_HANGEUL_CHARSET); |
| 764 if (!bFound && IsHasCharSet(languages, charSets)) { | 764 if (!bFound && IsHasCharSet(languages, charSets)) { |
| 765 cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H"; | 765 cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H"; |
| 766 ordering = "Korea1"; | 766 ordering = "Korea1"; |
| 767 supplement = 2; | 767 supplement = 2; |
| 768 pWidthArray->AddInteger(1); | 768 pWidthArray->AddInteger(1); |
| 769 _InsertWidthArray(font, 0x20, 0x7e, pWidthArray); | 769 _InsertWidthArray(font, 0x20, 0x7e, pWidthArray); |
| 770 bFound = TRUE; | 770 bFound = true; |
| 771 } | 771 } |
| 772 charSets.RemoveAll(); | 772 charSets.RemoveAll(); |
| 773 charSets.Add(FXFONT_SHIFTJIS_CHARSET); | 773 charSets.Add(FXFONT_SHIFTJIS_CHARSET); |
| 774 if (!bFound && IsHasCharSet(languages, charSets)) { | 774 if (!bFound && IsHasCharSet(languages, charSets)) { |
| 775 cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H"; | 775 cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H"; |
| 776 ordering = "Japan1"; | 776 ordering = "Japan1"; |
| 777 supplement = 5; | 777 supplement = 5; |
| 778 pWidthArray->AddInteger(231); | 778 pWidthArray->AddInteger(231); |
| 779 _InsertWidthArray(font, 0x20, 0x7d, pWidthArray); | 779 _InsertWidthArray(font, 0x20, 0x7d, pWidthArray); |
| 780 pWidthArray->AddInteger(326); | 780 pWidthArray->AddInteger(326); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 pWidthArray->AddInteger(*widths); | 859 pWidthArray->AddInteger(*widths); |
| 860 } else { | 860 } else { |
| 861 CPDF_Array* pWidthArray1 = new CPDF_Array; | 861 CPDF_Array* pWidthArray1 = new CPDF_Array; |
| 862 pWidthArray->Add(pWidthArray1); | 862 pWidthArray->Add(pWidthArray1); |
| 863 for (i = 0; i < size; i ++) { | 863 for (i = 0; i < size; i ++) { |
| 864 pWidthArray1->AddInteger(widths[i]); | 864 pWidthArray1->AddInteger(widths[i]); |
| 865 } | 865 } |
| 866 } | 866 } |
| 867 FX_Free(widths); | 867 FX_Free(widths); |
| 868 } | 868 } |
| 869 CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) | 869 CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, bool bVert) |
| 870 { | 870 { |
| 871 if (pFont == NULL) { | 871 if (pFont == NULL) { |
| 872 return NULL; | 872 return NULL; |
| 873 } | 873 } |
| 874 FX_BOOL bCJK = charset == FXFONT_CHINESEBIG5_CHARSET || charset == FXFONT_GB
2312_CHARSET || | 874 bool bCJK = charset == FXFONT_CHINESEBIG5_CHARSET || charset == FXFONT_GB231
2_CHARSET || |
| 875 charset == FXFONT_HANGEUL_CHARSET || charset == FXFONT_SHIFTJ
IS_CHARSET; | 875 charset == FXFONT_HANGEUL_CHARSET || charset == FXFONT_SHIFTJ
IS_CHARSET; |
| 876 CFX_ByteString basefont = pFont->GetFamilyName(); | 876 CFX_ByteString basefont = pFont->GetFamilyName(); |
| 877 basefont.Replace(" ", ""); | 877 basefont.Replace(" ", ""); |
| 878 int flags = 0; | 878 int flags = 0; |
| 879 if (pFont->IsBold()) { | 879 if (pFont->IsBold()) { |
| 880 flags |= PDFFONT_FORCEBOLD; | 880 flags |= PDFFONT_FORCEBOLD; |
| 881 } | 881 } |
| 882 if (pFont->IsItalic()) { | 882 if (pFont->IsItalic()) { |
| 883 flags |= PDFFONT_ITALIC; | 883 flags |= PDFFONT_ITALIC; |
| 884 } | 884 } |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 } | 1044 } |
| 1045 } | 1045 } |
| 1046 } | 1046 } |
| 1047 delete pEncoding; | 1047 delete pEncoding; |
| 1048 pFontDesc->SetAtInteger("StemV", nStemV); | 1048 pFontDesc->SetAtInteger("StemV", nStemV); |
| 1049 AddIndirectObject(pFontDesc); | 1049 AddIndirectObject(pFontDesc); |
| 1050 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); | 1050 pFontDict->SetAtReference("FontDescriptor", this, pFontDesc); |
| 1051 return LoadFont(pBaseDict); | 1051 return LoadFont(pBaseDict); |
| 1052 } | 1052 } |
| 1053 static int InsertDeletePDFPage(CPDF_Document* pDoc, CPDF_Dictionary* pPages, | 1053 static int InsertDeletePDFPage(CPDF_Document* pDoc, CPDF_Dictionary* pPages, |
| 1054 int nPagesToGo, CPDF_Dictionary* pPage, FX_BOOL b
Insert, CFX_PtrArray& stackList) | 1054 int nPagesToGo, CPDF_Dictionary* pPage, bool bIns
ert, CFX_PtrArray& stackList) |
| 1055 { | 1055 { |
| 1056 CPDF_Array* pKidList = pPages->GetArray("Kids"); | 1056 CPDF_Array* pKidList = pPages->GetArray("Kids"); |
| 1057 if (!pKidList) { | 1057 if (!pKidList) { |
| 1058 return -1; | 1058 return -1; |
| 1059 } | 1059 } |
| 1060 int nKids = pKidList->GetCount(); | 1060 int nKids = pKidList->GetCount(); |
| 1061 for (int i = 0; i < nKids; i ++) { | 1061 for (int i = 0; i < nKids; i ++) { |
| 1062 CPDF_Dictionary* pKid = pKidList->GetDict(i); | 1062 CPDF_Dictionary* pKid = pKidList->GetDict(i); |
| 1063 if (pKid->GetString("Type") == FX_BSTRC("Page")) { | 1063 if (pKid->GetString("Type") == FX_BSTRC("Page")) { |
| 1064 if (nPagesToGo == 0) { | 1064 if (nPagesToGo == 0) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 if (!pPagesList) { | 1114 if (!pPagesList) { |
| 1115 pPagesList = new CPDF_Array; | 1115 pPagesList = new CPDF_Array; |
| 1116 pPages->SetAt(FX_BSTRC("Kids"), pPagesList); | 1116 pPages->SetAt(FX_BSTRC("Kids"), pPagesList); |
| 1117 } | 1117 } |
| 1118 pPagesList->Add(pPageDict, pDoc); | 1118 pPagesList->Add(pPageDict, pDoc); |
| 1119 pPages->SetAtInteger(FX_BSTRC("Count"), nPages + 1); | 1119 pPages->SetAtInteger(FX_BSTRC("Count"), nPages + 1); |
| 1120 pPageDict->SetAtReference(FX_BSTRC("Parent"), pDoc, pPages->GetObjNum())
; | 1120 pPageDict->SetAtReference(FX_BSTRC("Parent"), pDoc, pPages->GetObjNum())
; |
| 1121 } else { | 1121 } else { |
| 1122 CFX_PtrArray stack; | 1122 CFX_PtrArray stack; |
| 1123 stack.Add(pPages); | 1123 stack.Add(pPages); |
| 1124 if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, TRUE, stack) < 0
) { | 1124 if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, true, stack) < 0
) { |
| 1125 return -1; | 1125 return -1; |
| 1126 } | 1126 } |
| 1127 } | 1127 } |
| 1128 pageList.InsertAt(iPage, pPageDict->GetObjNum()); | 1128 pageList.InsertAt(iPage, pPageDict->GetObjNum()); |
| 1129 return iPage; | 1129 return iPage; |
| 1130 } | 1130 } |
| 1131 CPDF_Dictionary* CPDF_Document::CreateNewPage(int iPage) | 1131 CPDF_Dictionary* CPDF_Document::CreateNewPage(int iPage) |
| 1132 { | 1132 { |
| 1133 CPDF_Dictionary* pDict = new CPDF_Dictionary; | 1133 CPDF_Dictionary* pDict = new CPDF_Dictionary; |
| 1134 pDict->SetAtName("Type", "Page"); | 1134 pDict->SetAtName("Type", "Page"); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1157 CPDF_Dictionary* pPages = pRoot->GetDict("Pages"); | 1157 CPDF_Dictionary* pPages = pRoot->GetDict("Pages"); |
| 1158 if (pPages == NULL) { | 1158 if (pPages == NULL) { |
| 1159 return; | 1159 return; |
| 1160 } | 1160 } |
| 1161 int nPages = pPages->GetInteger("Count"); | 1161 int nPages = pPages->GetInteger("Count"); |
| 1162 if (iPage < 0 || iPage >= nPages) { | 1162 if (iPage < 0 || iPage >= nPages) { |
| 1163 return; | 1163 return; |
| 1164 } | 1164 } |
| 1165 CFX_PtrArray stack; | 1165 CFX_PtrArray stack; |
| 1166 stack.Add(pPages); | 1166 stack.Add(pPages); |
| 1167 if (InsertDeletePDFPage(this, pPages, iPage, NULL, FALSE, stack) < 0) { | 1167 if (InsertDeletePDFPage(this, pPages, iPage, NULL, false, stack) < 0) { |
| 1168 return; | 1168 return; |
| 1169 } | 1169 } |
| 1170 m_PageList.RemoveAt(iPage); | 1170 m_PageList.RemoveAt(iPage); |
| 1171 } | 1171 } |
| 1172 CPDF_Object* FPDFAPI_GetPageAttr(CPDF_Dictionary* pPageDict, const CFX_ByteStrin
gC& name); | 1172 CPDF_Object* FPDFAPI_GetPageAttr(CPDF_Dictionary* pPageDict, const CFX_ByteStrin
gC& name); |
| 1173 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, const CFX_ByteStringC& nam
e) | 1173 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, const CFX_ByteStringC& nam
e) |
| 1174 { | 1174 { |
| 1175 if (pPageDict->KeyExist(name)) { | 1175 if (pPageDict->KeyExist(name)) { |
| 1176 return; | 1176 return; |
| 1177 } | 1177 } |
| 1178 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name); | 1178 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name); |
| 1179 if (pObj) { | 1179 if (pObj) { |
| 1180 pPageDict->SetAt(name, pObj->Clone()); | 1180 pPageDict->SetAt(name, pObj->Clone()); |
| 1181 } | 1181 } |
| 1182 } | 1182 } |
| OLD | NEW |