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

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

Issue 1888893002: Make CPDF_ApSettings take CFX_ByteString args. (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 | core/fpdfdoc/include/fpdf_doc.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 <algorithm> 7 #include <algorithm>
8 8
9 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" 9 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 return static_cast<HighlightingMode>(i); 194 return static_cast<HighlightingMode>(i);
195 } 195 }
196 return Invert; 196 return Invert;
197 } 197 }
198 198
199 CPDF_ApSettings CPDF_FormControl::GetMK() const { 199 CPDF_ApSettings CPDF_FormControl::GetMK() const {
200 return CPDF_ApSettings(m_pWidgetDict ? m_pWidgetDict->GetDictBy("MK") 200 return CPDF_ApSettings(m_pWidgetDict ? m_pWidgetDict->GetDictBy("MK")
201 : nullptr); 201 : nullptr);
202 } 202 }
203 203
204 bool CPDF_FormControl::HasMKEntry(CFX_ByteString csEntry) const { 204 bool CPDF_FormControl::HasMKEntry(const CFX_ByteString& csEntry) const {
205 return GetMK().HasMKEntry(csEntry.AsStringC()); 205 return GetMK().HasMKEntry(csEntry);
206 } 206 }
207 207
208 int CPDF_FormControl::GetRotation() { 208 int CPDF_FormControl::GetRotation() {
209 return GetMK().GetRotation(); 209 return GetMK().GetRotation();
210 } 210 }
211 211
212 FX_ARGB CPDF_FormControl::GetColor(int& iColorType, CFX_ByteString csEntry) { 212 FX_ARGB CPDF_FormControl::GetColor(int& iColorType,
213 return GetMK().GetColor(iColorType, csEntry.AsStringC()); 213 const CFX_ByteString& csEntry) {
214 return GetMK().GetColor(iColorType, csEntry);
214 } 215 }
215 216
216 FX_FLOAT CPDF_FormControl::GetOriginalColor(int index, CFX_ByteString csEntry) { 217 FX_FLOAT CPDF_FormControl::GetOriginalColor(int index,
217 return GetMK().GetOriginalColor(index, csEntry.AsStringC()); 218 const CFX_ByteString& csEntry) {
219 return GetMK().GetOriginalColor(index, csEntry);
218 } 220 }
219 221
220 void CPDF_FormControl::GetOriginalColor(int& iColorType, 222 void CPDF_FormControl::GetOriginalColor(int& iColorType,
221 FX_FLOAT fc[4], 223 FX_FLOAT fc[4],
222 CFX_ByteString csEntry) { 224 const CFX_ByteString& csEntry) {
223 GetMK().GetOriginalColor(iColorType, fc, csEntry.AsStringC()); 225 GetMK().GetOriginalColor(iColorType, fc, csEntry);
224 } 226 }
225 CFX_WideString CPDF_FormControl::GetCaption(CFX_ByteString csEntry) { 227 CFX_WideString CPDF_FormControl::GetCaption(const CFX_ByteString& csEntry) {
226 return GetMK().GetCaption(csEntry.AsStringC()); 228 return GetMK().GetCaption(csEntry);
227 } 229 }
228 230
229 CPDF_Stream* CPDF_FormControl::GetIcon(CFX_ByteString csEntry) { 231 CPDF_Stream* CPDF_FormControl::GetIcon(const CFX_ByteString& csEntry) {
230 return GetMK().GetIcon(csEntry.AsStringC()); 232 return GetMK().GetIcon(csEntry);
231 } 233 }
232 234
233 CPDF_IconFit CPDF_FormControl::GetIconFit() { 235 CPDF_IconFit CPDF_FormControl::GetIconFit() {
234 return GetMK().GetIconFit(); 236 return GetMK().GetIconFit();
235 } 237 }
236 238
237 int CPDF_FormControl::GetTextPosition() { 239 int CPDF_FormControl::GetTextPosition() {
238 return GetMK().GetTextPosition(); 240 return GetMK().GetTextPosition();
239 } 241 }
240 242
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 return m_pWidgetDict->GetIntegerBy("Q", 0); 325 return m_pWidgetDict->GetIntegerBy("Q", 0);
324 } 326 }
325 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "Q"); 327 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "Q");
326 if (pObj) 328 if (pObj)
327 return pObj->GetInteger(); 329 return pObj->GetInteger();
328 return m_pField->m_pForm->GetFormAlignment(); 330 return m_pField->m_pForm->GetFormAlignment();
329 } 331 }
330 332
331 CPDF_ApSettings::CPDF_ApSettings(CPDF_Dictionary* pDict) : m_pDict(pDict) {} 333 CPDF_ApSettings::CPDF_ApSettings(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
332 334
333 bool CPDF_ApSettings::HasMKEntry(const CFX_ByteStringC& csEntry) const { 335 bool CPDF_ApSettings::HasMKEntry(const CFX_ByteString& csEntry) const {
334 return m_pDict && m_pDict->KeyExist(csEntry); 336 return m_pDict && m_pDict->KeyExist(csEntry);
335 } 337 }
336 338
337 int CPDF_ApSettings::GetRotation() const { 339 int CPDF_ApSettings::GetRotation() const {
338 return m_pDict ? m_pDict->GetIntegerBy("R") : 0; 340 return m_pDict ? m_pDict->GetIntegerBy("R") : 0;
339 } 341 }
340 342
341 FX_ARGB CPDF_ApSettings::GetColor(int& iColorType, 343 FX_ARGB CPDF_ApSettings::GetColor(int& iColorType,
342 const CFX_ByteStringC& csEntry) const { 344 const CFX_ByteString& csEntry) const {
343 iColorType = COLORTYPE_TRANSPARENT; 345 iColorType = COLORTYPE_TRANSPARENT;
344 if (!m_pDict) 346 if (!m_pDict)
345 return 0; 347 return 0;
346 348
347 CPDF_Array* pEntry = m_pDict->GetArrayBy(csEntry); 349 CPDF_Array* pEntry = m_pDict->GetArrayBy(csEntry);
348 if (!pEntry) 350 if (!pEntry)
349 return 0; 351 return 0;
350 352
351 FX_ARGB color = 0; 353 FX_ARGB color = 0;
352 size_t dwCount = pEntry->GetCount(); 354 size_t dwCount = pEntry->GetCount();
(...skipping 16 matching lines...) Expand all
369 FX_FLOAT r = 1.0f - std::min(1.0f, c + k); 371 FX_FLOAT r = 1.0f - std::min(1.0f, c + k);
370 FX_FLOAT g = 1.0f - std::min(1.0f, m + k); 372 FX_FLOAT g = 1.0f - std::min(1.0f, m + k);
371 FX_FLOAT b = 1.0f - std::min(1.0f, y + k); 373 FX_FLOAT b = 1.0f - std::min(1.0f, y + k);
372 color = ArgbEncode(255, (int)(r * 255), (int)(g * 255), (int)(b * 255)); 374 color = ArgbEncode(255, (int)(r * 255), (int)(g * 255), (int)(b * 255));
373 } 375 }
374 return color; 376 return color;
375 } 377 }
376 378
377 FX_FLOAT CPDF_ApSettings::GetOriginalColor( 379 FX_FLOAT CPDF_ApSettings::GetOriginalColor(
378 int index, 380 int index,
379 const CFX_ByteStringC& csEntry) const { 381 const CFX_ByteString& csEntry) const {
380 if (!m_pDict) 382 if (!m_pDict)
381 return 0; 383 return 0;
382 384
383 CPDF_Array* pEntry = m_pDict->GetArrayBy(csEntry); 385 CPDF_Array* pEntry = m_pDict->GetArrayBy(csEntry);
384 return pEntry ? pEntry->GetNumberAt(index) : 0; 386 return pEntry ? pEntry->GetNumberAt(index) : 0;
385 } 387 }
386 388
387 void CPDF_ApSettings::GetOriginalColor(int& iColorType, 389 void CPDF_ApSettings::GetOriginalColor(int& iColorType,
388 FX_FLOAT fc[4], 390 FX_FLOAT fc[4],
389 const CFX_ByteStringC& csEntry) const { 391 const CFX_ByteString& csEntry) const {
390 iColorType = COLORTYPE_TRANSPARENT; 392 iColorType = COLORTYPE_TRANSPARENT;
391 for (int i = 0; i < 4; i++) { 393 for (int i = 0; i < 4; i++) {
392 fc[i] = 0; 394 fc[i] = 0;
393 } 395 }
394 if (!m_pDict) { 396 if (!m_pDict) {
395 return; 397 return;
396 } 398 }
397 CPDF_Array* pEntry = m_pDict->GetArrayBy(csEntry); 399 CPDF_Array* pEntry = m_pDict->GetArrayBy(csEntry);
398 if (!pEntry) { 400 if (!pEntry) {
399 return; 401 return;
(...skipping 10 matching lines...) Expand all
410 } else if (dwCount == 4) { 412 } else if (dwCount == 4) {
411 iColorType = COLORTYPE_CMYK; 413 iColorType = COLORTYPE_CMYK;
412 fc[0] = pEntry->GetNumberAt(0); 414 fc[0] = pEntry->GetNumberAt(0);
413 fc[1] = pEntry->GetNumberAt(1); 415 fc[1] = pEntry->GetNumberAt(1);
414 fc[2] = pEntry->GetNumberAt(2); 416 fc[2] = pEntry->GetNumberAt(2);
415 fc[3] = pEntry->GetNumberAt(3); 417 fc[3] = pEntry->GetNumberAt(3);
416 } 418 }
417 } 419 }
418 420
419 CFX_WideString CPDF_ApSettings::GetCaption( 421 CFX_WideString CPDF_ApSettings::GetCaption(
420 const CFX_ByteStringC& csEntry) const { 422 const CFX_ByteString& csEntry) const {
421 return m_pDict ? m_pDict->GetUnicodeTextBy(csEntry) : CFX_WideString(); 423 return m_pDict ? m_pDict->GetUnicodeTextBy(csEntry) : CFX_WideString();
422 } 424 }
423 425
424 CPDF_Stream* CPDF_ApSettings::GetIcon(const CFX_ByteStringC& csEntry) const { 426 CPDF_Stream* CPDF_ApSettings::GetIcon(const CFX_ByteString& csEntry) const {
425 return m_pDict ? m_pDict->GetStreamBy(csEntry) : nullptr; 427 return m_pDict ? m_pDict->GetStreamBy(csEntry) : nullptr;
426 } 428 }
427 429
428 CPDF_IconFit CPDF_ApSettings::GetIconFit() const { 430 CPDF_IconFit CPDF_ApSettings::GetIconFit() const {
429 return CPDF_IconFit(m_pDict ? m_pDict->GetDictBy("IF") : nullptr); 431 return CPDF_IconFit(m_pDict ? m_pDict->GetDictBy("IF") : nullptr);
430 } 432 }
431 433
432 int CPDF_ApSettings::GetTextPosition() const { 434 int CPDF_ApSettings::GetTextPosition() const {
433 return m_pDict ? m_pDict->GetIntegerBy("TP", TEXTPOS_CAPTION) 435 return m_pDict ? m_pDict->GetIntegerBy("TP", TEXTPOS_CAPTION)
434 : TEXTPOS_CAPTION; 436 : TEXTPOS_CAPTION;
435 } 437 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfdoc/include/fpdf_doc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698