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

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

Issue 1751753002: Remove implicit conversions and some cleanup (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 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
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
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 239 }
240 if (m_pWidgetDict->KeyExist("A")) { 240 if (m_pWidgetDict->KeyExist("A")) {
241 return CPDF_Action(m_pWidgetDict->GetDictBy("A")); 241 return CPDF_Action(m_pWidgetDict->GetDictBy("A"));
242 } 242 }
243 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "A"); 243 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "A");
244 if (!pObj) { 244 if (!pObj) {
245 return CPDF_Action(); 245 return CPDF_Action();
246 } 246 }
247 return CPDF_Action(pObj->GetDict()); 247 return CPDF_Action(pObj->GetDict());
248 } 248 }
249
249 CPDF_AAction CPDF_FormControl::GetAdditionalAction() { 250 CPDF_AAction CPDF_FormControl::GetAdditionalAction() {
250 if (!m_pWidgetDict) { 251 CPDF_Dictionary* dict = nullptr;
251 return nullptr; 252 if (m_pWidgetDict) {
Tom Sepez 2016/03/01 17:53:35 Same thing here with no-arg ctor.
Wei Li 2016/03/01 21:46:53 Done.
253 if (m_pWidgetDict->KeyExist("AA"))
254 dict = m_pWidgetDict->GetDictBy("AA");
255 else
256 dict = m_pField->GetAdditionalAction();
252 } 257 }
253 if (m_pWidgetDict->KeyExist("AA")) { 258 return CPDF_AAction(dict);
254 return m_pWidgetDict->GetDictBy("AA"); 259 }
260
261 CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() {
262 CFX_ByteString str;
263 if (m_pWidgetDict) {
264 if (m_pWidgetDict->KeyExist("DA")) {
265 str = m_pWidgetDict->GetStringBy("DA");
266 } else {
267 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "DA");
268 str =
269 pObj ? pObj->GetString() : m_pField->m_pForm->GetDefaultAppearance();
270 }
255 } 271 }
256 return m_pField->GetAdditionalAction(); 272 return CPDF_DefaultAppearance(str);
257 }
258 CPDF_DefaultAppearance CPDF_FormControl::GetDefaultAppearance() {
259 if (!m_pWidgetDict) {
260 return CFX_ByteString();
261 }
262 if (m_pWidgetDict->KeyExist("DA")) {
263 return m_pWidgetDict->GetStringBy("DA");
264 }
265 CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "DA");
266 if (!pObj) {
267 return m_pField->m_pForm->GetDefaultAppearance();
268 }
269 return pObj->GetString();
270 } 273 }
271 274
272 CPDF_Font* CPDF_FormControl::GetDefaultControlFont() { 275 CPDF_Font* CPDF_FormControl::GetDefaultControlFont() {
273 CPDF_DefaultAppearance cDA = GetDefaultAppearance(); 276 CPDF_DefaultAppearance cDA = GetDefaultAppearance();
274 CFX_ByteString csFontNameTag; 277 CFX_ByteString csFontNameTag;
275 FX_FLOAT fFontSize; 278 FX_FLOAT fFontSize;
276 cDA.GetFont(csFontNameTag, fFontSize); 279 cDA.GetFont(csFontNameTag, fFontSize);
277 if (csFontNameTag.IsEmpty()) 280 if (csFontNameTag.IsEmpty())
278 return nullptr; 281 return nullptr;
279 282
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 CFX_WideString CPDF_ApSettings::GetCaption( 417 CFX_WideString CPDF_ApSettings::GetCaption(
415 const CFX_ByteStringC& csEntry) const { 418 const CFX_ByteStringC& csEntry) const {
416 return m_pDict ? m_pDict->GetUnicodeTextBy(csEntry) : CFX_WideString(); 419 return m_pDict ? m_pDict->GetUnicodeTextBy(csEntry) : CFX_WideString();
417 } 420 }
418 421
419 CPDF_Stream* CPDF_ApSettings::GetIcon(const CFX_ByteStringC& csEntry) const { 422 CPDF_Stream* CPDF_ApSettings::GetIcon(const CFX_ByteStringC& csEntry) const {
420 return m_pDict ? m_pDict->GetStreamBy(csEntry) : nullptr; 423 return m_pDict ? m_pDict->GetStreamBy(csEntry) : nullptr;
421 } 424 }
422 425
423 CPDF_IconFit CPDF_ApSettings::GetIconFit() const { 426 CPDF_IconFit CPDF_ApSettings::GetIconFit() const {
424 return m_pDict ? m_pDict->GetDictBy("IF") : nullptr; 427 return CPDF_IconFit(m_pDict ? m_pDict->GetDictBy("IF") : nullptr);
425 } 428 }
426 429
427 int CPDF_ApSettings::GetTextPosition() const { 430 int CPDF_ApSettings::GetTextPosition() const {
428 return m_pDict ? m_pDict->GetIntegerBy("TP", TEXTPOS_CAPTION) 431 return m_pDict ? m_pDict->GetIntegerBy("TP", TEXTPOS_CAPTION)
429 : TEXTPOS_CAPTION; 432 : TEXTPOS_CAPTION;
430 } 433 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698