Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: core/fpdfapi/parser/cpdf_document.cpp

Issue 2477443002: Remove FX_BOOL from core (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfapi/parser/cpdf_document.h ('k') | core/fpdfapi/parser/cpdf_object.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "core/fpdfapi/parser/cpdf_document.h" 7 #include "core/fpdfapi/parser/cpdf_document.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 int glyph_index = pEncoding->GlyphFromCharCode(start + i); 237 int glyph_index = pEncoding->GlyphFromCharCode(start + i);
238 widths[i] = pFont->GetGlyphWidth(glyph_index); 238 widths[i] = pFont->GetGlyphWidth(glyph_index);
239 } 239 }
240 InsertWidthArrayImpl(widths, size, pWidthArray); 240 InsertWidthArrayImpl(widths, size, pWidthArray);
241 } 241 }
242 242
243 int InsertDeletePDFPage(CPDF_Document* pDoc, 243 int InsertDeletePDFPage(CPDF_Document* pDoc,
244 CPDF_Dictionary* pPages, 244 CPDF_Dictionary* pPages,
245 int nPagesToGo, 245 int nPagesToGo,
246 CPDF_Dictionary* pPage, 246 CPDF_Dictionary* pPage,
247 FX_BOOL bInsert, 247 bool bInsert,
248 std::set<CPDF_Dictionary*>* pVisited) { 248 std::set<CPDF_Dictionary*>* pVisited) {
249 CPDF_Array* pKidList = pPages->GetArrayFor("Kids"); 249 CPDF_Array* pKidList = pPages->GetArrayFor("Kids");
250 if (!pKidList) 250 if (!pKidList)
251 return -1; 251 return -1;
252 252
253 for (size_t i = 0; i < pKidList->GetCount(); i++) { 253 for (size_t i = 0; i < pKidList->GetCount(); i++) {
254 CPDF_Dictionary* pKid = pKidList->GetDictAt(i); 254 CPDF_Dictionary* pKid = pKidList->GetDictAt(i);
255 if (pKid->GetStringFor("Type") == "Page") { 255 if (pKid->GetStringFor("Type") == "Page") {
256 if (nPagesToGo == 0) { 256 if (nPagesToGo == 0) {
257 if (bInsert) { 257 if (bInsert) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 CPDF_Array* pPagesList = pPages->GetArrayFor("Kids"); 303 CPDF_Array* pPagesList = pPages->GetArrayFor("Kids");
304 if (!pPagesList) { 304 if (!pPagesList) {
305 pPagesList = new CPDF_Array; 305 pPagesList = new CPDF_Array;
306 pPages->SetFor("Kids", pPagesList); 306 pPages->SetFor("Kids", pPagesList);
307 } 307 }
308 pPagesList->Add(new CPDF_Reference(pDoc, pPageDict->GetObjNum())); 308 pPagesList->Add(new CPDF_Reference(pDoc, pPageDict->GetObjNum()));
309 pPages->SetIntegerFor("Count", nPages + 1); 309 pPages->SetIntegerFor("Count", nPages + 1);
310 pPageDict->SetReferenceFor("Parent", pDoc, pPages->GetObjNum()); 310 pPageDict->SetReferenceFor("Parent", pDoc, pPages->GetObjNum());
311 } else { 311 } else {
312 std::set<CPDF_Dictionary*> stack = {pPages}; 312 std::set<CPDF_Dictionary*> stack = {pPages};
313 if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, TRUE, &stack) < 0) 313 if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, true, &stack) < 0)
314 return -1; 314 return -1;
315 } 315 }
316 pageList.InsertAt(iPage, pPageDict->GetObjNum()); 316 pageList.InsertAt(iPage, pPageDict->GetObjNum());
317 return iPage; 317 return iPage;
318 } 318 }
319 319
320 int CountPages(CPDF_Dictionary* pPages, 320 int CountPages(CPDF_Dictionary* pPages,
321 std::set<CPDF_Dictionary*>* visited_pages) { 321 std::set<CPDF_Dictionary*>* visited_pages) {
322 int count = pPages->GetIntegerFor("Count"); 322 int count = pPages->GetIntegerFor("Count");
323 if (count > 0 && count < FPDF_PAGE_MAX_NUM) 323 if (count > 0 && count < FPDF_PAGE_MAX_NUM)
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 void CPDF_Document::DeletePage(int iPage) { 720 void CPDF_Document::DeletePage(int iPage) {
721 CPDF_Dictionary* pPages = GetPagesDict(); 721 CPDF_Dictionary* pPages = GetPagesDict();
722 if (!pPages) 722 if (!pPages)
723 return; 723 return;
724 724
725 int nPages = pPages->GetIntegerFor("Count"); 725 int nPages = pPages->GetIntegerFor("Count");
726 if (iPage < 0 || iPage >= nPages) 726 if (iPage < 0 || iPage >= nPages)
727 return; 727 return;
728 728
729 std::set<CPDF_Dictionary*> stack = {pPages}; 729 std::set<CPDF_Dictionary*> stack = {pPages};
730 if (InsertDeletePDFPage(this, pPages, iPage, nullptr, FALSE, &stack) < 0) 730 if (InsertDeletePDFPage(this, pPages, iPage, nullptr, false, &stack) < 0)
731 return; 731 return;
732 732
733 m_PageList.RemoveAt(iPage); 733 m_PageList.RemoveAt(iPage);
734 } 734 }
735 735
736 CPDF_Font* CPDF_Document::AddStandardFont(const FX_CHAR* font, 736 CPDF_Font* CPDF_Document::AddStandardFont(const FX_CHAR* font,
737 CPDF_FontEncoding* pEncoding) { 737 CPDF_FontEncoding* pEncoding) {
738 CFX_ByteString name(font); 738 CFX_ByteString name(font);
739 if (PDF_GetStandardFontName(&name) < 0) 739 if (PDF_GetStandardFontName(&name) < 0)
740 return nullptr; 740 return nullptr;
(...skipping 21 matching lines...) Expand all
762 pEncodingDict->SetFor("Differences", pArray); 762 pEncodingDict->SetFor("Differences", pArray);
763 pBaseDict->SetReferenceFor("Encoding", this, 763 pBaseDict->SetReferenceFor("Encoding", this,
764 AddIndirectObject(pEncodingDict)); 764 AddIndirectObject(pEncodingDict));
765 765
766 return i; 766 return i;
767 } 767 }
768 768
769 CPDF_Dictionary* CPDF_Document::ProcessbCJK( 769 CPDF_Dictionary* CPDF_Document::ProcessbCJK(
770 CPDF_Dictionary* pBaseDict, 770 CPDF_Dictionary* pBaseDict,
771 int charset, 771 int charset,
772 FX_BOOL bVert, 772 bool bVert,
773 CFX_ByteString basefont, 773 CFX_ByteString basefont,
774 std::function<void(FX_WCHAR, FX_WCHAR, CPDF_Array*)> Insert) { 774 std::function<void(FX_WCHAR, FX_WCHAR, CPDF_Array*)> Insert) {
775 CPDF_Dictionary* pFontDict = new CPDF_Dictionary(m_pByteStringPool); 775 CPDF_Dictionary* pFontDict = new CPDF_Dictionary(m_pByteStringPool);
776 CFX_ByteString cmap; 776 CFX_ByteString cmap;
777 CFX_ByteString ordering; 777 CFX_ByteString ordering;
778 int supplement = 0; 778 int supplement = 0;
779 CPDF_Array* pWidthArray = new CPDF_Array; 779 CPDF_Array* pWidthArray = new CPDF_Array;
780 switch (charset) { 780 switch (charset) {
781 case FXFONT_CHINESEBIG5_CHARSET: 781 case FXFONT_CHINESEBIG5_CHARSET:
782 cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H"; 782 cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H";
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 pCIDSysInfo->SetStringFor("Registry", "Adobe"); 826 pCIDSysInfo->SetStringFor("Registry", "Adobe");
827 pCIDSysInfo->SetStringFor("Ordering", ordering); 827 pCIDSysInfo->SetStringFor("Ordering", ordering);
828 pCIDSysInfo->SetIntegerFor("Supplement", supplement); 828 pCIDSysInfo->SetIntegerFor("Supplement", supplement);
829 pFontDict->SetFor("CIDSystemInfo", pCIDSysInfo); 829 pFontDict->SetFor("CIDSystemInfo", pCIDSysInfo);
830 CPDF_Array* pArray = new CPDF_Array; 830 CPDF_Array* pArray = new CPDF_Array;
831 pBaseDict->SetFor("DescendantFonts", pArray); 831 pBaseDict->SetFor("DescendantFonts", pArray);
832 pArray->AddReference(this, AddIndirectObject(pFontDict)); 832 pArray->AddReference(this, AddIndirectObject(pFontDict));
833 return pFontDict; 833 return pFontDict;
834 } 834 }
835 835
836 CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) { 836 CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, bool bVert) {
837 if (!pFont) 837 if (!pFont)
838 return nullptr; 838 return nullptr;
839 839
840 bool bCJK = charset == FXFONT_CHINESEBIG5_CHARSET || 840 bool bCJK = charset == FXFONT_CHINESEBIG5_CHARSET ||
841 charset == FXFONT_GB2312_CHARSET || 841 charset == FXFONT_GB2312_CHARSET ||
842 charset == FXFONT_HANGUL_CHARSET || 842 charset == FXFONT_HANGUL_CHARSET ||
843 charset == FXFONT_SHIFTJIS_CHARSET; 843 charset == FXFONT_SHIFTJIS_CHARSET;
844 CFX_ByteString basefont = pFont->GetFamilyName(); 844 CFX_ByteString basefont = pFont->GetFamilyName();
845 basefont.Replace(" ", ""); 845 basefont.Replace(" ", "");
846 int flags = 846 int flags =
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 CPDF_Dictionary* pFontDesc = 916 CPDF_Dictionary* pFontDesc =
917 CalculateFontDesc(this, basefont, flags, italicangle, pFont->GetAscent(), 917 CalculateFontDesc(this, basefont, flags, italicangle, pFont->GetAscent(),
918 pFont->GetDescent(), pBBox, nStemV); 918 pFont->GetDescent(), pBBox, nStemV);
919 pFontDict->SetReferenceFor("FontDescriptor", this, 919 pFontDict->SetReferenceFor("FontDescriptor", this,
920 AddIndirectObject(pFontDesc)); 920 AddIndirectObject(pFontDesc));
921 return LoadFont(pBaseDict); 921 return LoadFont(pBaseDict);
922 } 922 }
923 923
924 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 924 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
925 CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTW* pLogFont, 925 CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTW* pLogFont,
926 FX_BOOL bVert, 926 bool bVert,
927 FX_BOOL bTranslateName) { 927 bool bTranslateName) {
928 LOGFONTA lfa; 928 LOGFONTA lfa;
929 FXSYS_memcpy(&lfa, pLogFont, (char*)lfa.lfFaceName - (char*)&lfa); 929 FXSYS_memcpy(&lfa, pLogFont, (char*)lfa.lfFaceName - (char*)&lfa);
930 CFX_ByteString face = CFX_ByteString::FromUnicode(pLogFont->lfFaceName); 930 CFX_ByteString face = CFX_ByteString::FromUnicode(pLogFont->lfFaceName);
931 if (face.GetLength() >= LF_FACESIZE) 931 if (face.GetLength() >= LF_FACESIZE)
932 return nullptr; 932 return nullptr;
933 933
934 FXSYS_strcpy(lfa.lfFaceName, face.c_str()); 934 FXSYS_strcpy(lfa.lfFaceName, face.c_str());
935 return AddWindowsFont(&lfa, bVert, bTranslateName); 935 return AddWindowsFont(&lfa, bVert, bTranslateName);
936 } 936 }
937 937
938 CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont, 938 CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont,
939 FX_BOOL bVert, 939 bool bVert,
940 FX_BOOL bTranslateName) { 940 bool bTranslateName) {
941 pLogFont->lfHeight = -1000; 941 pLogFont->lfHeight = -1000;
942 pLogFont->lfWidth = 0; 942 pLogFont->lfWidth = 0;
943 HGDIOBJ hFont = CreateFontIndirectA(pLogFont); 943 HGDIOBJ hFont = CreateFontIndirectA(pLogFont);
944 HDC hDC = CreateCompatibleDC(nullptr); 944 HDC hDC = CreateCompatibleDC(nullptr);
945 hFont = SelectObject(hDC, hFont); 945 hFont = SelectObject(hDC, hFont);
946 int tm_size = GetOutlineTextMetrics(hDC, 0, nullptr); 946 int tm_size = GetOutlineTextMetrics(hDC, 0, nullptr);
947 if (tm_size == 0) { 947 if (tm_size == 0) {
948 hFont = SelectObject(hDC, hFont); 948 hFont = SelectObject(hDC, hFont);
949 DeleteObject(hFont); 949 DeleteObject(hFont);
950 DeleteDC(hDC); 950 DeleteDC(hDC);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 pBBox, pLogFont->lfWeight / 5); 1013 pBBox, pLogFont->lfWeight / 5);
1014 pFontDesc->SetIntegerFor("CapHeight", capheight); 1014 pFontDesc->SetIntegerFor("CapHeight", capheight);
1015 pFontDict->SetReferenceFor("FontDescriptor", this, 1015 pFontDict->SetReferenceFor("FontDescriptor", this,
1016 AddIndirectObject(pFontDesc)); 1016 AddIndirectObject(pFontDesc));
1017 hFont = SelectObject(hDC, hFont); 1017 hFont = SelectObject(hDC, hFont);
1018 DeleteObject(hFont); 1018 DeleteObject(hFont);
1019 DeleteDC(hDC); 1019 DeleteDC(hDC);
1020 return LoadFont(pBaseDict); 1020 return LoadFont(pBaseDict);
1021 } 1021 }
1022 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 1022 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
OLDNEW
« no previous file with comments | « core/fpdfapi/parser/cpdf_document.h ('k') | core/fpdfapi/parser/cpdf_object.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698