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

Side by Side Diff: core/fpdfapi/fpdf_page/fpdf_page_parser.cpp

Issue 1847333004: Remove _FXBSTR* and calls to FX_BSTRC. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months 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 | « no previous file | xfa/fde/css/fde_css.h » ('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/fpdf_page/pageint.h" 7 #include "core/fpdfapi/fpdf_page/pageint.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 23 matching lines...) Expand all
34 namespace { 34 namespace {
35 35
36 const char kPathOperatorSubpath = 'm'; 36 const char kPathOperatorSubpath = 'm';
37 const char kPathOperatorLine = 'l'; 37 const char kPathOperatorLine = 'l';
38 const char kPathOperatorCubicBezier1 = 'c'; 38 const char kPathOperatorCubicBezier1 = 'c';
39 const char kPathOperatorCubicBezier2 = 'v'; 39 const char kPathOperatorCubicBezier2 = 'v';
40 const char kPathOperatorCubicBezier3 = 'y'; 40 const char kPathOperatorCubicBezier3 = 'y';
41 const char kPathOperatorClosePath = 'h'; 41 const char kPathOperatorClosePath = 'h';
42 const char kPathOperatorRectangle[] = "re"; 42 const char kPathOperatorRectangle[] = "re";
43 43
44 struct _FX_BSTR { 44 struct PDF_AbbrPair {
45 const FX_CHAR* m_Ptr; 45 const FX_CHAR* full_name;
46 int m_Size; 46 const FX_CHAR* abbr;
47 };
48 #define _FX_BSTRC(str) \
49 { str, sizeof(str) - 1 }
50
51 struct PDF_AbbrPairs {
52 _FX_BSTR full_name;
53 _FX_BSTR abbr;
54 }; 47 };
55 48
56 const PDF_AbbrPairs PDF_InlineKeyAbbr[] = { 49 const PDF_AbbrPair PDF_InlineKeyAbbr[] = {
57 {_FX_BSTRC("BitsPerComponent"), _FX_BSTRC("BPC")}, 50 {"BitsPerComponent", "BPC"}, {"ColorSpace", "CS"}, {"Decode", "D"},
58 {_FX_BSTRC("ColorSpace"), _FX_BSTRC("CS")}, 51 {"DecodeParms", "DP"}, {"Filter", "F"}, {"Height", "H"},
59 {_FX_BSTRC("Decode"), _FX_BSTRC("D")}, 52 {"ImageMask", "IM"}, {"Interpolate", "I"}, {"Width", "W"},
60 {_FX_BSTRC("DecodeParms"), _FX_BSTRC("DP")},
61 {_FX_BSTRC("Filter"), _FX_BSTRC("F")},
62 {_FX_BSTRC("Height"), _FX_BSTRC("H")},
63 {_FX_BSTRC("ImageMask"), _FX_BSTRC("IM")},
64 {_FX_BSTRC("Interpolate"), _FX_BSTRC("I")},
65 {_FX_BSTRC("Width"), _FX_BSTRC("W")},
66 }; 53 };
67 54
68 const PDF_AbbrPairs PDF_InlineValueAbbr[] = { 55 const PDF_AbbrPair PDF_InlineValueAbbr[] = {
69 {_FX_BSTRC("DeviceGray"), _FX_BSTRC("G")}, 56 {"DeviceGray", "G"}, {"DeviceRGB", "RGB"},
70 {_FX_BSTRC("DeviceRGB"), _FX_BSTRC("RGB")}, 57 {"DeviceCMYK", "CMYK"}, {"Indexed", "I"},
71 {_FX_BSTRC("DeviceCMYK"), _FX_BSTRC("CMYK")}, 58 {"ASCIIHexDecode", "AHx"}, {"ASCII85Decode", "A85"},
72 {_FX_BSTRC("Indexed"), _FX_BSTRC("I")}, 59 {"LZWDecode", "LZW"}, {"FlateDecode", "Fl"},
73 {_FX_BSTRC("ASCIIHexDecode"), _FX_BSTRC("AHx")}, 60 {"RunLengthDecode", "RL"}, {"CCITTFaxDecode", "CCF"},
74 {_FX_BSTRC("ASCII85Decode"), _FX_BSTRC("A85")}, 61 {"DCTDecode", "DCT"},
75 {_FX_BSTRC("LZWDecode"), _FX_BSTRC("LZW")},
76 {_FX_BSTRC("FlateDecode"), _FX_BSTRC("Fl")},
77 {_FX_BSTRC("RunLengthDecode"), _FX_BSTRC("RL")},
78 {_FX_BSTRC("CCITTFaxDecode"), _FX_BSTRC("CCF")},
79 {_FX_BSTRC("DCTDecode"), _FX_BSTRC("DCT")},
80 }; 62 };
81 63
82 struct AbbrReplacementOp { 64 struct AbbrReplacementOp {
83 bool is_replace_key; 65 bool is_replace_key;
84 CFX_ByteString key; 66 CFX_ByteString key;
85 CFX_ByteStringC replacement; 67 CFX_ByteStringC replacement;
86 }; 68 };
87 69
88 class CPDF_StreamParserAutoClearer { 70 class CPDF_StreamParserAutoClearer {
89 public: 71 public:
90 CPDF_StreamParserAutoClearer(CPDF_StreamParser** scoped_variable, 72 CPDF_StreamParserAutoClearer(CPDF_StreamParser** scoped_variable,
91 CPDF_StreamParser* new_parser) 73 CPDF_StreamParser* new_parser)
92 : scoped_variable_(scoped_variable) { 74 : scoped_variable_(scoped_variable) {
93 *scoped_variable_ = new_parser; 75 *scoped_variable_ = new_parser;
94 } 76 }
95 ~CPDF_StreamParserAutoClearer() { *scoped_variable_ = NULL; } 77 ~CPDF_StreamParserAutoClearer() { *scoped_variable_ = NULL; }
96 78
97 private: 79 private:
98 CPDF_StreamParser** scoped_variable_; 80 CPDF_StreamParser** scoped_variable_;
99 }; 81 };
100 82
101 CFX_ByteStringC PDF_FindFullName(const PDF_AbbrPairs* table, 83 CFX_ByteStringC PDF_FindFullName(const PDF_AbbrPair* table,
dsinclair 2016/04/02 00:13:33 What's your preference for testing something like
Tom Sepez 2016/04/02 18:11:54 Dunno. May not require a unit test, even, if we hi
dsinclair 2016/04/04 15:21:14 Done. Add ForTesting wrappers and some simple uni
102 size_t count, 84 size_t count,
103 const CFX_ByteStringC& abbr) { 85 const CFX_ByteStringC& abbr) {
104 for (size_t i = 0; i < count; ++i) { 86 for (size_t i = 0; i < count; ++i) {
105 if (abbr.GetLength() != table[i].abbr.m_Size) 87 if (abbr.GetLength() < 0 || table[i].abbr[abbr.GetLength() + 1] != '\0')
106 continue; 88 continue;
107 if (memcmp(abbr.GetPtr(), table[i].abbr.m_Ptr, abbr.GetLength())) 89 if (memcmp(abbr.GetPtr(), table[i].abbr, abbr.GetLength()))
108 continue; 90 continue;
109 return CFX_ByteStringC(table[i].full_name.m_Ptr, table[i].full_name.m_Size); 91 return CFX_ByteStringC(table[i].full_name);
110 } 92 }
111 return CFX_ByteStringC(); 93 return CFX_ByteStringC();
112 } 94 }
113 95
114 } // namespace 96 } // namespace
115 97
116 bool IsPathOperator(const uint8_t* buf, size_t len) { 98 bool IsPathOperator(const uint8_t* buf, size_t len) {
117 if (len == 1) { 99 if (len == 1) {
118 uint8_t op = buf[0]; 100 uint8_t op = buf[0];
119 if (op == kPathOperatorSubpath || op == kPathOperatorLine || 101 if (op == kPathOperatorSubpath || op == kPathOperatorLine ||
(...skipping 1701 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 } else { 1803 } else {
1822 PDF_ReplaceAbbr(pElement); 1804 PDF_ReplaceAbbr(pElement);
1823 } 1805 }
1824 } 1806 }
1825 break; 1807 break;
1826 } 1808 }
1827 default: 1809 default:
1828 break; 1810 break;
1829 } 1811 }
1830 } 1812 }
OLDNEW
« no previous file with comments | « no previous file | xfa/fde/css/fde_css.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698