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

Side by Side Diff: core/src/fpdfdoc/doc_formcontrol.cpp

Issue 1644633003: Member function name refactoring (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 10 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 | « core/src/fpdfdoc/doc_form.cpp ('k') | core/src/fpdfdoc/doc_formfield.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 <algorithm> 7 #include <algorithm>
8 8
9 #include "core/include/fpdfdoc/fpdf_doc.h" 9 #include "core/include/fpdfdoc/fpdf_doc.h"
10 10
11 CPDF_FormControl::CPDF_FormControl(CPDF_FormField* pField, 11 CPDF_FormControl::CPDF_FormControl(CPDF_FormField* pField,
12 CPDF_Dictionary* pWidgetDict) { 12 CPDF_Dictionary* pWidgetDict) {
13 m_pField = pField; 13 m_pField = pField;
14 m_pWidgetDict = pWidgetDict; 14 m_pWidgetDict = pWidgetDict;
15 m_pForm = m_pField->m_pForm; 15 m_pForm = m_pField->m_pForm;
16 } 16 }
17 CFX_FloatRect CPDF_FormControl::GetRect() const { 17 CFX_FloatRect CPDF_FormControl::GetRect() const {
18 return m_pWidgetDict->GetRect("Rect"); 18 return m_pWidgetDict->GetRectBy("Rect");
19 } 19 }
20 CFX_ByteString CPDF_FormControl::GetOnStateName() { 20 CFX_ByteString CPDF_FormControl::GetOnStateName() {
21 ASSERT(GetType() == CPDF_FormField::CheckBox || 21 ASSERT(GetType() == CPDF_FormField::CheckBox ||
22 GetType() == CPDF_FormField::RadioButton); 22 GetType() == CPDF_FormField::RadioButton);
23 CFX_ByteString csOn; 23 CFX_ByteString csOn;
24 CPDF_Dictionary* pAP = m_pWidgetDict->GetDict("AP"); 24 CPDF_Dictionary* pAP = m_pWidgetDict->GetDictBy("AP");
25 if (!pAP) { 25 if (!pAP) {
26 return csOn; 26 return csOn;
27 } 27 }
28 CPDF_Dictionary* pN = pAP->GetDict("N"); 28 CPDF_Dictionary* pN = pAP->GetDictBy("N");
29 if (!pN) { 29 if (!pN) {
30 return csOn; 30 return csOn;
31 } 31 }
32 for (const auto& it : *pN) { 32 for (const auto& it : *pN) {
33 if (it.first != "Off") { 33 if (it.first != "Off") {
34 return it.first; 34 return it.first;
35 } 35 }
36 } 36 }
37 return CFX_ByteString(); 37 return CFX_ByteString();
38 } 38 }
39 void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) { 39 void CPDF_FormControl::SetOnStateName(const CFX_ByteString& csOn) {
40 ASSERT(GetType() == CPDF_FormField::CheckBox || 40 ASSERT(GetType() == CPDF_FormField::CheckBox ||
41 GetType() == CPDF_FormField::RadioButton); 41 GetType() == CPDF_FormField::RadioButton);
42 CFX_ByteString csValue = csOn; 42 CFX_ByteString csValue = csOn;
43 if (csValue.IsEmpty()) { 43 if (csValue.IsEmpty()) {
44 csValue = "Yes"; 44 csValue = "Yes";
45 } 45 }
46 if (csValue == "Off") { 46 if (csValue == "Off") {
47 csValue = "Yes"; 47 csValue = "Yes";
48 } 48 }
49 CFX_ByteString csAS = m_pWidgetDict->GetString("AS", "Off"); 49 CFX_ByteString csAS = m_pWidgetDict->GetStringBy("AS", "Off");
50 if (csAS != "Off") { 50 if (csAS != "Off") {
51 m_pWidgetDict->SetAtName("AS", csValue); 51 m_pWidgetDict->SetAtName("AS", csValue);
52 } 52 }
53 CPDF_Dictionary* pAP = m_pWidgetDict->GetDict("AP"); 53 CPDF_Dictionary* pAP = m_pWidgetDict->GetDictBy("AP");
54 if (!pAP) { 54 if (!pAP) {
55 return; 55 return;
56 } 56 }
57 for (const auto& it : *pAP) { 57 for (const auto& it : *pAP) {
58 CPDF_Object* pObj1 = it.second; 58 CPDF_Object* pObj1 = it.second;
59 if (!pObj1) { 59 if (!pObj1) {
60 continue; 60 continue;
61 } 61 }
62 CPDF_Object* pObjDirect1 = pObj1->GetDirect(); 62 CPDF_Object* pObjDirect1 = pObj1->GetDirect();
63 CPDF_Dictionary* pSubDict = pObjDirect1->AsDictionary(); 63 CPDF_Dictionary* pSubDict = pObjDirect1->AsDictionary();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 } 96 }
97 CFX_WideString CPDF_FormControl::GetExportValue() { 97 CFX_WideString CPDF_FormControl::GetExportValue() {
98 ASSERT(GetType() == CPDF_FormField::CheckBox || 98 ASSERT(GetType() == CPDF_FormField::CheckBox ||
99 GetType() == CPDF_FormField::RadioButton); 99 GetType() == CPDF_FormField::RadioButton);
100 CFX_ByteString csOn = GetOnStateName(); 100 CFX_ByteString csOn = GetOnStateName();
101 if (GetType() == CPDF_FormField::RadioButton || 101 if (GetType() == CPDF_FormField::RadioButton ||
102 GetType() == CPDF_FormField::CheckBox) { 102 GetType() == CPDF_FormField::CheckBox) {
103 if (CPDF_Array* pArray = 103 if (CPDF_Array* pArray =
104 ToArray(FPDF_GetFieldAttr(m_pField->m_pDict, "Opt"))) { 104 ToArray(FPDF_GetFieldAttr(m_pField->m_pDict, "Opt"))) {
105 int iIndex = m_pField->GetControlIndex(this); 105 int iIndex = m_pField->GetControlIndex(this);
106 csOn = pArray->GetString(iIndex); 106 csOn = pArray->GetStringAt(iIndex);
107 } 107 }
108 } 108 }
109 if (csOn.IsEmpty()) { 109 if (csOn.IsEmpty()) {
110 csOn = "Yes"; 110 csOn = "Yes";
111 } 111 }
112 CFX_WideString csWOn = PDF_DecodeText(csOn); 112 CFX_WideString csWOn = PDF_DecodeText(csOn);
113 return csWOn; 113 return csWOn;
114 } 114 }
115 FX_BOOL CPDF_FormControl::IsChecked() { 115 FX_BOOL CPDF_FormControl::IsChecked() {
116 ASSERT(GetType() == CPDF_FormField::CheckBox || 116 ASSERT(GetType() == CPDF_FormField::CheckBox ||
117 GetType() == CPDF_FormField::RadioButton); 117 GetType() == CPDF_FormField::RadioButton);
118 CFX_ByteString csOn = GetOnStateName(); 118 CFX_ByteString csOn = GetOnStateName();
119 CFX_ByteString csAS = m_pWidgetDict->GetString("AS"); 119 CFX_ByteString csAS = m_pWidgetDict->GetStringBy("AS");
120 return csAS == csOn; 120 return csAS == csOn;
121 } 121 }
122 FX_BOOL CPDF_FormControl::IsDefaultChecked() { 122 FX_BOOL CPDF_FormControl::IsDefaultChecked() {
123 ASSERT(GetType() == CPDF_FormField::CheckBox || 123 ASSERT(GetType() == CPDF_FormField::CheckBox ||
124 GetType() == CPDF_FormField::RadioButton); 124 GetType() == CPDF_FormField::RadioButton);
125 CPDF_Object* pDV = FPDF_GetFieldAttr(m_pField->m_pDict, "DV"); 125 CPDF_Object* pDV = FPDF_GetFieldAttr(m_pField->m_pDict, "DV");
126 if (!pDV) { 126 if (!pDV) {
127 return FALSE; 127 return FALSE;
128 } 128 }
129 CFX_ByteString csDV = pDV->GetString(); 129 CFX_ByteString csDV = pDV->GetString();
130 CFX_ByteString csOn = GetOnStateName(); 130 CFX_ByteString csOn = GetOnStateName();
131 return (csDV == csOn); 131 return (csDV == csOn);
132 } 132 }
133 void CPDF_FormControl::CheckControl(FX_BOOL bChecked) { 133 void CPDF_FormControl::CheckControl(FX_BOOL bChecked) {
134 ASSERT(GetType() == CPDF_FormField::CheckBox || 134 ASSERT(GetType() == CPDF_FormField::CheckBox ||
135 GetType() == CPDF_FormField::RadioButton); 135 GetType() == CPDF_FormField::RadioButton);
136 CFX_ByteString csOn = GetOnStateName(); 136 CFX_ByteString csOn = GetOnStateName();
137 CFX_ByteString csOldAS = m_pWidgetDict->GetString("AS", "Off"); 137 CFX_ByteString csOldAS = m_pWidgetDict->GetStringBy("AS", "Off");
138 CFX_ByteString csAS = "Off"; 138 CFX_ByteString csAS = "Off";
139 if (bChecked) { 139 if (bChecked) {
140 csAS = csOn; 140 csAS = csOn;
141 } 141 }
142 if (csOldAS == csAS) { 142 if (csOldAS == csAS) {
143 return; 143 return;
144 } 144 }
145 m_pWidgetDict->SetAtName("AS", csAS); 145 m_pWidgetDict->SetAtName("AS", csAS);
146 m_pForm->m_bUpdated = TRUE; 146 m_pForm->m_bUpdated = TRUE;
147 } 147 }
148 CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, 148 CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict,
149 CPDF_Annot::AppearanceMode mode); 149 CPDF_Annot::AppearanceMode mode);
150 void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice, 150 void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice,
151 CFX_Matrix* pMatrix, 151 CFX_Matrix* pMatrix,
152 CPDF_Page* pPage, 152 CPDF_Page* pPage,
153 CPDF_Annot::AppearanceMode mode, 153 CPDF_Annot::AppearanceMode mode,
154 const CPDF_RenderOptions* pOptions) { 154 const CPDF_RenderOptions* pOptions) {
155 if (m_pWidgetDict->GetInteger("F") & ANNOTFLAG_HIDDEN) { 155 if (m_pWidgetDict->GetIntegerBy("F") & ANNOTFLAG_HIDDEN) {
156 return; 156 return;
157 } 157 }
158 CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pWidgetDict, mode); 158 CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pWidgetDict, mode);
159 if (!pStream) { 159 if (!pStream) {
160 return; 160 return;
161 } 161 }
162 CFX_FloatRect form_bbox = pStream->GetDict()->GetRect("BBox"); 162 CFX_FloatRect form_bbox = pStream->GetDict()->GetRectBy("BBox");
163 CFX_Matrix form_matrix = pStream->GetDict()->GetMatrix("Matrix"); 163 CFX_Matrix form_matrix = pStream->GetDict()->GetMatrixBy("Matrix");
164 form_matrix.TransformRect(form_bbox); 164 form_matrix.TransformRect(form_bbox);
165 CFX_FloatRect arect = m_pWidgetDict->GetRect("Rect"); 165 CFX_FloatRect arect = m_pWidgetDict->GetRectBy("Rect");
166 CFX_Matrix matrix; 166 CFX_Matrix matrix;
167 matrix.MatchRect(arect, form_bbox); 167 matrix.MatchRect(arect, form_bbox);
168 matrix.Concat(*pMatrix); 168 matrix.Concat(*pMatrix);
169 CPDF_Form form(m_pField->m_pForm->m_pDocument, 169 CPDF_Form form(m_pField->m_pForm->m_pDocument,
170 m_pField->m_pForm->m_pFormDict->GetDict("DR"), pStream); 170 m_pField->m_pForm->m_pFormDict->GetDictBy("DR"), pStream);
171 form.ParseContent(NULL, NULL, NULL, NULL); 171 form.ParseContent(NULL, NULL, NULL, NULL);
172 CPDF_RenderContext context(pPage); 172 CPDF_RenderContext context(pPage);
173 context.AppendLayer(&form, &matrix); 173 context.AppendLayer(&form, &matrix);
174 context.Render(pDevice, pOptions, nullptr); 174 context.Render(pDevice, pOptions, nullptr);
175 } 175 }
176 static const FX_CHAR* const g_sHighlightingMode[] = { 176 static const FX_CHAR* const g_sHighlightingMode[] = {
177 // Must match order of HiglightingMode enum. 177 // Must match order of HiglightingMode enum.
178 "N", "I", "O", "P", "T", nullptr}; 178 "N", "I", "O", "P", "T", nullptr};
179 CPDF_FormControl::HighlightingMode CPDF_FormControl::GetHighlightingMode() { 179 CPDF_FormControl::HighlightingMode CPDF_FormControl::GetHighlightingMode() {
180 if (!m_pWidgetDict) { 180 if (!m_pWidgetDict) {
181 return Invert; 181 return Invert;
182 } 182 }
183 CFX_ByteString csH = m_pWidgetDict->GetString("H", "I"); 183 CFX_ByteString csH = m_pWidgetDict->GetStringBy("H", "I");
184 for (int i = 0; g_sHighlightingMode[i]; ++i) { 184 for (int i = 0; g_sHighlightingMode[i]; ++i) {
185 if (csH.Equal(g_sHighlightingMode[i])) 185 if (csH.Equal(g_sHighlightingMode[i]))
186 return static_cast<HighlightingMode>(i); 186 return static_cast<HighlightingMode>(i);
187 } 187 }
188 return Invert; 188 return Invert;
189 } 189 }
190 190
191 CPDF_ApSettings CPDF_FormControl::GetMK() const { 191 CPDF_ApSettings CPDF_FormControl::GetMK() const {
192 return CPDF_ApSettings(m_pWidgetDict ? m_pWidgetDict->GetDict("MK") 192 return CPDF_ApSettings(m_pWidgetDict ? m_pWidgetDict->GetDictBy("MK")
193 : nullptr); 193 : nullptr);
194 } 194 }
195 195
196 bool CPDF_FormControl::HasMKEntry(CFX_ByteString csEntry) const { 196 bool CPDF_FormControl::HasMKEntry(CFX_ByteString csEntry) const {
197 return GetMK().HasMKEntry(csEntry); 197 return GetMK().HasMKEntry(csEntry);
198 } 198 }
199 199
200 int CPDF_FormControl::GetRotation() { 200 int CPDF_FormControl::GetRotation() {
201 return GetMK().GetRotation(); 201 return GetMK().GetRotation();
202 } 202 }
(...skipping 25 matching lines...) Expand all
228 228
229 int CPDF_FormControl::GetTextPosition() { 229 int CPDF_FormControl::GetTextPosition() {
230 return GetMK().GetTextPosition(); 230 return GetMK().GetTextPosition();
231 } 231 }
232 232
233 CPDF_Action CPDF_FormControl::GetAction() { 233 CPDF_Action CPDF_FormControl::GetAction() {
234 if (!m_pWidgetDict) { 234 if (!m_pWidgetDict) {
235 return CPDF_Action(); 235 return CPDF_Action();
236 } 236 }
237 if (m_pWidgetDict->KeyExist("A")) { 237 if (m_pWidgetDict->KeyExist("A")) {
238 return CPDF_Action(m_pWidgetDict->GetDict("A")); 238 return CPDF_Action(m_pWidgetDict->GetDictBy("A"));
239 } 239 }
240 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "A"); 240 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "A");
241 if (!pObj) { 241 if (!pObj) {
242 return CPDF_Action(); 242 return CPDF_Action();
243 } 243 }
244 return CPDF_Action(pObj->GetDict()); 244 return CPDF_Action(pObj->GetDict());
245 } 245 }
246 CPDF_AAction CPDF_FormControl::GetAdditionalAction() { 246 CPDF_AAction CPDF_FormControl::GetAdditionalAction() {
247 if (!m_pWidgetDict) { 247 if (!m_pWidgetDict) {
248 return nullptr; 248 return nullptr;
249 } 249 }
250 if (m_pWidgetDict->KeyExist("AA")) { 250 if (m_pWidgetDict->KeyExist("AA")) {
251 return m_pWidgetDict->GetDict("AA"); 251 return m_pWidgetDict->GetDictBy("AA");
252 } 252 }
253 return m_pField->GetAdditionalAction(); 253 return m_pField->GetAdditionalAction();
254 } 254 }
255 CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() { 255 CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() {
256 if (!m_pWidgetDict) { 256 if (!m_pWidgetDict) {
257 return CFX_ByteString(); 257 return CFX_ByteString();
258 } 258 }
259 if (m_pWidgetDict->KeyExist("DA")) { 259 if (m_pWidgetDict->KeyExist("DA")) {
260 return m_pWidgetDict->GetString("DA"); 260 return m_pWidgetDict->GetStringBy("DA");
261 } 261 }
262 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "DA"); 262 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "DA");
263 if (!pObj) { 263 if (!pObj) {
264 return m_pField->m_pForm->GetDefaultAppearance(); 264 return m_pField->m_pForm->GetDefaultAppearance();
265 } 265 }
266 return pObj->GetString(); 266 return pObj->GetString();
267 } 267 }
268 268
269 CPDF_Font* CPDF_FormControl::GetDefaultControlFont() { 269 CPDF_Font* CPDF_FormControl::GetDefaultControlFont() {
270 CPDF_DefaultAppearance cDA = GetDefaultAppearance(); 270 CPDF_DefaultAppearance cDA = GetDefaultAppearance();
271 CFX_ByteString csFontNameTag; 271 CFX_ByteString csFontNameTag;
272 FX_FLOAT fFontSize; 272 FX_FLOAT fFontSize;
273 cDA.GetFont(csFontNameTag, fFontSize); 273 cDA.GetFont(csFontNameTag, fFontSize);
274 if (csFontNameTag.IsEmpty()) 274 if (csFontNameTag.IsEmpty())
275 return nullptr; 275 return nullptr;
276 276
277 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pWidgetDict, "DR"); 277 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pWidgetDict, "DR");
278 if (CPDF_Dictionary* pDict = ToDictionary(pObj)) { 278 if (CPDF_Dictionary* pDict = ToDictionary(pObj)) {
279 CPDF_Dictionary* pFonts = pDict->GetDict("Font"); 279 CPDF_Dictionary* pFonts = pDict->GetDictBy("Font");
280 if (pFonts) { 280 if (pFonts) {
281 CPDF_Dictionary* pElement = pFonts->GetDict(csFontNameTag); 281 CPDF_Dictionary* pElement = pFonts->GetDictBy(csFontNameTag);
282 if (pElement) { 282 if (pElement) {
283 CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement); 283 CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement);
284 if (pFont) { 284 if (pFont) {
285 return pFont; 285 return pFont;
286 } 286 }
287 } 287 }
288 } 288 }
289 } 289 }
290 if (CPDF_Font* pFormFont = m_pField->m_pForm->GetFormFont(csFontNameTag)) 290 if (CPDF_Font* pFormFont = m_pField->m_pForm->GetFormFont(csFontNameTag))
291 return pFormFont; 291 return pFormFont;
292 292
293 CPDF_Dictionary* pPageDict = m_pWidgetDict->GetDict("P"); 293 CPDF_Dictionary* pPageDict = m_pWidgetDict->GetDictBy("P");
294 pObj = FPDF_GetFieldAttr(pPageDict, "Resources"); 294 pObj = FPDF_GetFieldAttr(pPageDict, "Resources");
295 if (CPDF_Dictionary* pDict = ToDictionary(pObj)) { 295 if (CPDF_Dictionary* pDict = ToDictionary(pObj)) {
296 CPDF_Dictionary* pFonts = pDict->GetDict("Font"); 296 CPDF_Dictionary* pFonts = pDict->GetDictBy("Font");
297 if (pFonts) { 297 if (pFonts) {
298 CPDF_Dictionary* pElement = pFonts->GetDict(csFontNameTag); 298 CPDF_Dictionary* pElement = pFonts->GetDictBy(csFontNameTag);
299 if (pElement) { 299 if (pElement) {
300 CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement); 300 CPDF_Font* pFont = m_pField->m_pForm->m_pDocument->LoadFont(pElement);
301 if (pFont) { 301 if (pFont) {
302 return pFont; 302 return pFont;
303 } 303 }
304 } 304 }
305 } 305 }
306 } 306 }
307 return nullptr; 307 return nullptr;
308 } 308 }
309 309
310 int CPDF_FormControl::GetControlAlignment() { 310 int CPDF_FormControl::GetControlAlignment() {
311 if (!m_pWidgetDict) { 311 if (!m_pWidgetDict) {
312 return 0; 312 return 0;
313 } 313 }
314 if (m_pWidgetDict->KeyExist("Q")) { 314 if (m_pWidgetDict->KeyExist("Q")) {
315 return m_pWidgetDict->GetInteger("Q", 0); 315 return m_pWidgetDict->GetIntegerBy("Q", 0);
316 } 316 }
317 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "Q"); 317 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "Q");
318 if (pObj) 318 if (pObj)
319 return pObj->GetInteger(); 319 return pObj->GetInteger();
320 return m_pField->m_pForm->GetFormAlignment(); 320 return m_pField->m_pForm->GetFormAlignment();
321 } 321 }
322 322
323 CPDF_ApSettings::CPDF_ApSettings(CPDF_Dictionary* pDict) : m_pDict(pDict) {} 323 CPDF_ApSettings::CPDF_ApSettings(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
324 324
325 bool CPDF_ApSettings::HasMKEntry(const CFX_ByteStringC& csEntry) const { 325 bool CPDF_ApSettings::HasMKEntry(const CFX_ByteStringC& csEntry) const {
326 return m_pDict && m_pDict->KeyExist(csEntry); 326 return m_pDict && m_pDict->KeyExist(csEntry);
327 } 327 }
328 328
329 int CPDF_ApSettings::GetRotation() const { 329 int CPDF_ApSettings::GetRotation() const {
330 return m_pDict ? m_pDict->GetInteger("R") : 0; 330 return m_pDict ? m_pDict->GetIntegerBy("R") : 0;
331 } 331 }
332 332
333 FX_ARGB CPDF_ApSettings::GetColor(int& iColorType, 333 FX_ARGB CPDF_ApSettings::GetColor(int& iColorType,
334 const CFX_ByteStringC& csEntry) const { 334 const CFX_ByteStringC& csEntry) const {
335 iColorType = COLORTYPE_TRANSPARENT; 335 iColorType = COLORTYPE_TRANSPARENT;
336 if (!m_pDict) 336 if (!m_pDict)
337 return 0; 337 return 0;
338 338
339 CPDF_Array* pEntry = m_pDict->GetArray(csEntry); 339 CPDF_Array* pEntry = m_pDict->GetArrayBy(csEntry);
340 if (!pEntry) 340 if (!pEntry)
341 return 0; 341 return 0;
342 342
343 FX_ARGB color = 0; 343 FX_ARGB color = 0;
344 FX_DWORD dwCount = pEntry->GetCount(); 344 FX_DWORD dwCount = pEntry->GetCount();
345 if (dwCount == 1) { 345 if (dwCount == 1) {
346 iColorType = COLORTYPE_GRAY; 346 iColorType = COLORTYPE_GRAY;
347 FX_FLOAT g = pEntry->GetNumber(0) * 255; 347 FX_FLOAT g = pEntry->GetNumberAt(0) * 255;
348 color = ArgbEncode(255, (int)g, (int)g, (int)g); 348 color = ArgbEncode(255, (int)g, (int)g, (int)g);
349 } else if (dwCount == 3) { 349 } else if (dwCount == 3) {
350 iColorType = COLORTYPE_RGB; 350 iColorType = COLORTYPE_RGB;
351 FX_FLOAT r = pEntry->GetNumber(0) * 255; 351 FX_FLOAT r = pEntry->GetNumberAt(0) * 255;
352 FX_FLOAT g = pEntry->GetNumber(1) * 255; 352 FX_FLOAT g = pEntry->GetNumberAt(1) * 255;
353 FX_FLOAT b = pEntry->GetNumber(2) * 255; 353 FX_FLOAT b = pEntry->GetNumberAt(2) * 255;
354 color = ArgbEncode(255, (int)r, (int)g, (int)b); 354 color = ArgbEncode(255, (int)r, (int)g, (int)b);
355 } else if (dwCount == 4) { 355 } else if (dwCount == 4) {
356 iColorType = COLORTYPE_CMYK; 356 iColorType = COLORTYPE_CMYK;
357 FX_FLOAT c = pEntry->GetNumber(0); 357 FX_FLOAT c = pEntry->GetNumberAt(0);
358 FX_FLOAT m = pEntry->GetNumber(1); 358 FX_FLOAT m = pEntry->GetNumberAt(1);
359 FX_FLOAT y = pEntry->GetNumber(2); 359 FX_FLOAT y = pEntry->GetNumberAt(2);
360 FX_FLOAT k = pEntry->GetNumber(3); 360 FX_FLOAT k = pEntry->GetNumberAt(3);
361 FX_FLOAT r = 1.0f - std::min(1.0f, c + k); 361 FX_FLOAT r = 1.0f - std::min(1.0f, c + k);
362 FX_FLOAT g = 1.0f - std::min(1.0f, m + k); 362 FX_FLOAT g = 1.0f - std::min(1.0f, m + k);
363 FX_FLOAT b = 1.0f - std::min(1.0f, y + k); 363 FX_FLOAT b = 1.0f - std::min(1.0f, y + k);
364 color = ArgbEncode(255, (int)(r * 255), (int)(g * 255), (int)(b * 255)); 364 color = ArgbEncode(255, (int)(r * 255), (int)(g * 255), (int)(b * 255));
365 } 365 }
366 return color; 366 return color;
367 } 367 }
368 368
369 FX_FLOAT CPDF_ApSettings::GetOriginalColor( 369 FX_FLOAT CPDF_ApSettings::GetOriginalColor(
370 int index, 370 int index,
371 const CFX_ByteStringC& csEntry) const { 371 const CFX_ByteStringC& csEntry) const {
372 if (!m_pDict) 372 if (!m_pDict)
373 return 0; 373 return 0;
374 374
375 CPDF_Array* pEntry = m_pDict->GetArray(csEntry); 375 CPDF_Array* pEntry = m_pDict->GetArrayBy(csEntry);
376 return pEntry ? pEntry->GetNumber(index) : 0; 376 return pEntry ? pEntry->GetNumberAt(index) : 0;
377 } 377 }
378 378
379 void CPDF_ApSettings::GetOriginalColor(int& iColorType, 379 void CPDF_ApSettings::GetOriginalColor(int& iColorType,
380 FX_FLOAT fc[4], 380 FX_FLOAT fc[4],
381 const CFX_ByteStringC& csEntry) const { 381 const CFX_ByteStringC& csEntry) const {
382 iColorType = COLORTYPE_TRANSPARENT; 382 iColorType = COLORTYPE_TRANSPARENT;
383 for (int i = 0; i < 4; i++) { 383 for (int i = 0; i < 4; i++) {
384 fc[i] = 0; 384 fc[i] = 0;
385 } 385 }
386 if (!m_pDict) { 386 if (!m_pDict) {
387 return; 387 return;
388 } 388 }
389 CPDF_Array* pEntry = m_pDict->GetArray(csEntry); 389 CPDF_Array* pEntry = m_pDict->GetArrayBy(csEntry);
390 if (!pEntry) { 390 if (!pEntry) {
391 return; 391 return;
392 } 392 }
393 FX_DWORD dwCount = pEntry->GetCount(); 393 FX_DWORD dwCount = pEntry->GetCount();
394 if (dwCount == 1) { 394 if (dwCount == 1) {
395 iColorType = COLORTYPE_GRAY; 395 iColorType = COLORTYPE_GRAY;
396 fc[0] = pEntry->GetNumber(0); 396 fc[0] = pEntry->GetNumberAt(0);
397 } else if (dwCount == 3) { 397 } else if (dwCount == 3) {
398 iColorType = COLORTYPE_RGB; 398 iColorType = COLORTYPE_RGB;
399 fc[0] = pEntry->GetNumber(0); 399 fc[0] = pEntry->GetNumberAt(0);
400 fc[1] = pEntry->GetNumber(1); 400 fc[1] = pEntry->GetNumberAt(1);
401 fc[2] = pEntry->GetNumber(2); 401 fc[2] = pEntry->GetNumberAt(2);
402 } else if (dwCount == 4) { 402 } else if (dwCount == 4) {
403 iColorType = COLORTYPE_CMYK; 403 iColorType = COLORTYPE_CMYK;
404 fc[0] = pEntry->GetNumber(0); 404 fc[0] = pEntry->GetNumberAt(0);
405 fc[1] = pEntry->GetNumber(1); 405 fc[1] = pEntry->GetNumberAt(1);
406 fc[2] = pEntry->GetNumber(2); 406 fc[2] = pEntry->GetNumberAt(2);
407 fc[3] = pEntry->GetNumber(3); 407 fc[3] = pEntry->GetNumberAt(3);
408 } 408 }
409 } 409 }
410 410
411 CFX_WideString CPDF_ApSettings::GetCaption( 411 CFX_WideString CPDF_ApSettings::GetCaption(
412 const CFX_ByteStringC& csEntry) const { 412 const CFX_ByteStringC& csEntry) const {
413 return m_pDict ? m_pDict->GetUnicodeText(csEntry) : CFX_WideString(); 413 return m_pDict ? m_pDict->GetUnicodeTextBy(csEntry) : CFX_WideString();
414 } 414 }
415 415
416 CPDF_Stream* CPDF_ApSettings::GetIcon(const CFX_ByteStringC& csEntry) const { 416 CPDF_Stream* CPDF_ApSettings::GetIcon(const CFX_ByteStringC& csEntry) const {
417 return m_pDict ? m_pDict->GetStream(csEntry) : nullptr; 417 return m_pDict ? m_pDict->GetStreamBy(csEntry) : nullptr;
418 } 418 }
419 419
420 CPDF_IconFit CPDF_ApSettings::GetIconFit() const { 420 CPDF_IconFit CPDF_ApSettings::GetIconFit() const {
421 return m_pDict ? m_pDict->GetDict("IF") : nullptr; 421 return m_pDict ? m_pDict->GetDictBy("IF") : nullptr;
422 } 422 }
423 423
424 int CPDF_ApSettings::GetTextPosition() const { 424 int CPDF_ApSettings::GetTextPosition() const {
425 return m_pDict ? m_pDict->GetInteger("TP", TEXTPOS_CAPTION) : TEXTPOS_CAPTION; 425 return m_pDict ? m_pDict->GetIntegerBy("TP", TEXTPOS_CAPTION)
426 : TEXTPOS_CAPTION;
426 } 427 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_form.cpp ('k') | core/src/fpdfdoc/doc_formfield.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698