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

Side by Side Diff: fpdfsdk/fsdk_baseform.cpp

Issue 1862123003: Rename both As{Byte,Wide}StringC() helpers to AsStringC(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase, fix new usage. 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 | « fpdfsdk/fsdk_baseannot.cpp ('k') | fpdfsdk/fsdk_mgr.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 "fpdfsdk/include/fsdk_baseform.h" 7 #include "fpdfsdk/include/fsdk_baseform.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 CFX_WideString sName; 57 CFX_WideString sName;
58 if (GetFieldType() == FIELDTYPE_RADIOBUTTON) { 58 if (GetFieldType() == FIELDTYPE_RADIOBUTTON) {
59 sName = GetAnnotName(); 59 sName = GetAnnotName();
60 if (sName.IsEmpty()) 60 if (sName.IsEmpty())
61 sName = GetName(); 61 sName = GetName();
62 } else { 62 } else {
63 sName = GetName(); 63 sName = GetName();
64 } 64 }
65 65
66 if (!sName.IsEmpty()) 66 if (!sName.IsEmpty())
67 m_hMixXFAWidget = pDocView->GetWidgetByName(sName.AsWideStringC()); 67 m_hMixXFAWidget = pDocView->GetWidgetByName(sName.AsStringC());
68 } 68 }
69 } 69 }
70 return m_hMixXFAWidget; 70 return m_hMixXFAWidget;
71 } 71 }
72 72
73 return NULL; 73 return NULL;
74 } 74 }
75 75
76 CXFA_FFWidget* CPDFSDK_Widget::GetGroupMixXFAWidget() { 76 CXFA_FFWidget* CPDFSDK_Widget::GetGroupMixXFAWidget() {
77 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); 77 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument();
78 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); 78 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument();
79 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { 79 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) {
80 if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) { 80 if (CXFA_FFDocView* pDocView = pDoc->GetXFADocView()) {
81 CFX_WideString sName = GetName(); 81 CFX_WideString sName = GetName();
82 if (!sName.IsEmpty()) 82 if (!sName.IsEmpty())
83 return pDocView->GetWidgetByName(sName.AsWideStringC()); 83 return pDocView->GetWidgetByName(sName.AsStringC());
84 } 84 }
85 } 85 }
86 86
87 return nullptr; 87 return nullptr;
88 } 88 }
89 89
90 CXFA_FFWidgetHandler* CPDFSDK_Widget::GetXFAWidgetHandler() const { 90 CXFA_FFWidgetHandler* CPDFSDK_Widget::GetXFAWidgetHandler() const {
91 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument(); 91 CPDFSDK_Document* pSDKDoc = m_pPageView->GetSDKDocument();
92 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); 92 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument();
93 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { 93 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) {
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 switch (nFieldType) { 454 switch (nFieldType) {
455 case FIELDTYPE_PUSHBUTTON: 455 case FIELDTYPE_PUSHBUTTON:
456 case FIELDTYPE_COMBOBOX: 456 case FIELDTYPE_COMBOBOX:
457 case FIELDTYPE_LISTBOX: 457 case FIELDTYPE_LISTBOX:
458 case FIELDTYPE_TEXTFIELD: 458 case FIELDTYPE_TEXTFIELD:
459 case FIELDTYPE_SIGNATURE: 459 case FIELDTYPE_SIGNATURE:
460 return psub->IsStream(); 460 return psub->IsStream();
461 case FIELDTYPE_CHECKBOX: 461 case FIELDTYPE_CHECKBOX:
462 case FIELDTYPE_RADIOBUTTON: 462 case FIELDTYPE_RADIOBUTTON:
463 if (CPDF_Dictionary* pSubDict = psub->AsDictionary()) { 463 if (CPDF_Dictionary* pSubDict = psub->AsDictionary()) {
464 return !!pSubDict->GetStreamBy(GetAppState().AsByteStringC()); 464 return !!pSubDict->GetStreamBy(GetAppState().AsStringC());
465 } 465 }
466 return FALSE; 466 return FALSE;
467 } 467 }
468 return TRUE; 468 return TRUE;
469 } 469 }
470 470
471 int CPDFSDK_Widget::GetFieldType() const { 471 int CPDFSDK_Widget::GetFieldType() const {
472 return GetFormField()->GetFieldType(); 472 return GetFormField()->GetFieldType();
473 } 473 }
474 474
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 1801
1802 return crFill; 1802 return crFill;
1803 } 1803 }
1804 1804
1805 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, 1805 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType,
1806 CPDF_Stream* pImage) { 1806 CPDF_Stream* pImage) {
1807 CPDF_Document* pDoc = m_pPageView->GetPDFDocument(); 1807 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
1808 ASSERT(pDoc); 1808 ASSERT(pDoc);
1809 1809
1810 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP"); 1810 CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP");
1811 CPDF_Stream* pStream = pAPDict->GetStreamBy(sAPType.AsByteStringC()); 1811 CPDF_Stream* pStream = pAPDict->GetStreamBy(sAPType.AsStringC());
1812 CPDF_Dictionary* pStreamDict = pStream->GetDict(); 1812 CPDF_Dictionary* pStreamDict = pStream->GetDict();
1813 CFX_ByteString sImageAlias = "IMG"; 1813 CFX_ByteString sImageAlias = "IMG";
1814 1814
1815 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) { 1815 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) {
1816 sImageAlias = pImageDict->GetStringBy("Name"); 1816 sImageAlias = pImageDict->GetStringBy("Name");
1817 if (sImageAlias.IsEmpty()) 1817 if (sImageAlias.IsEmpty())
1818 sImageAlias = "IMG"; 1818 sImageAlias = "IMG";
1819 } 1819 }
1820 1820
1821 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources"); 1821 CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources");
1822 if (!pStreamResList) { 1822 if (!pStreamResList) {
1823 pStreamResList = new CPDF_Dictionary(); 1823 pStreamResList = new CPDF_Dictionary();
1824 pStreamDict->SetAt("Resources", pStreamResList); 1824 pStreamDict->SetAt("Resources", pStreamResList);
1825 } 1825 }
1826 1826
1827 if (pStreamResList) { 1827 if (pStreamResList) {
1828 CPDF_Dictionary* pXObject = new CPDF_Dictionary; 1828 CPDF_Dictionary* pXObject = new CPDF_Dictionary;
1829 pXObject->SetAtReference(sImageAlias.AsByteStringC(), pDoc, pImage); 1829 pXObject->SetAtReference(sImageAlias.AsStringC(), pDoc, pImage);
1830 pStreamResList->SetAt("XObject", pXObject); 1830 pStreamResList->SetAt("XObject", pXObject);
1831 } 1831 }
1832 } 1832 }
1833 1833
1834 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { 1834 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) {
1835 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP")) { 1835 if (CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP")) {
1836 pAPDict->RemoveAt(sAPType.AsByteStringC()); 1836 pAPDict->RemoveAt(sAPType.AsStringC());
1837 } 1837 }
1838 } 1838 }
1839 1839
1840 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, 1840 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type,
1841 PDFSDK_FieldAction& data, 1841 PDFSDK_FieldAction& data,
1842 CPDFSDK_PageView* pPageView) { 1842 CPDFSDK_PageView* pPageView) {
1843 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); 1843 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument();
1844 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); 1844 CPDFDoc_Environment* pEnv = pDocument->GetEnv();
1845 1845
1846 #ifdef PDF_ENABLE_XFA 1846 #ifdef PDF_ENABLE_XFA
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
2441 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize); 2441 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize);
2442 } 2442 }
2443 return TRUE; 2443 return TRUE;
2444 } 2444 }
2445 2445
2446 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf( 2446 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(
2447 const std::vector<CPDF_FormField*>& fields, 2447 const std::vector<CPDF_FormField*>& fields,
2448 bool bIncludeOrExclude, 2448 bool bIncludeOrExclude,
2449 CFX_ByteTextBuf& textBuf) { 2449 CFX_ByteTextBuf& textBuf) {
2450 std::unique_ptr<CFDF_Document> pFDF(m_pInterForm->ExportToFDF( 2450 std::unique_ptr<CFDF_Document> pFDF(m_pInterForm->ExportToFDF(
2451 m_pDocument->GetPath().AsWideStringC(), fields, bIncludeOrExclude)); 2451 m_pDocument->GetPath().AsStringC(), fields, bIncludeOrExclude));
2452 return pFDF ? pFDF->WriteBuf(textBuf) : FALSE; 2452 return pFDF ? pFDF->WriteBuf(textBuf) : FALSE;
2453 } 2453 }
2454 2454
2455 #ifdef PDF_ENABLE_XFA 2455 #ifdef PDF_ENABLE_XFA
2456 void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField, 2456 void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField,
2457 FX_BOOL bSynchronizeElse) { 2457 FX_BOOL bSynchronizeElse) {
2458 int x = 0; 2458 int x = 0;
2459 if (m_FieldSynchronizeMap.Lookup(pFormField, x)) 2459 if (m_FieldSynchronizeMap.Lookup(pFormField, x))
2460 return; 2460 return;
2461 2461
(...skipping 17 matching lines...) Expand all
2479 FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, 2479 FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination,
2480 FX_BOOL bUrlEncoded) { 2480 FX_BOOL bUrlEncoded) {
2481 if (sDestination.IsEmpty()) 2481 if (sDestination.IsEmpty())
2482 return FALSE; 2482 return FALSE;
2483 2483
2484 if (!m_pDocument || !m_pInterForm) 2484 if (!m_pDocument || !m_pInterForm)
2485 return FALSE; 2485 return FALSE;
2486 2486
2487 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); 2487 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv();
2488 CFX_WideString wsPDFFilePath = m_pDocument->GetPath(); 2488 CFX_WideString wsPDFFilePath = m_pDocument->GetPath();
2489 CFDF_Document* pFDFDoc = 2489 CFDF_Document* pFDFDoc = m_pInterForm->ExportToFDF(wsPDFFilePath.AsStringC());
2490 m_pInterForm->ExportToFDF(wsPDFFilePath.AsWideStringC());
2491 if (!pFDFDoc) 2490 if (!pFDFDoc)
2492 return FALSE; 2491 return FALSE;
2493 2492
2494 CFX_ByteTextBuf FdfBuffer; 2493 CFX_ByteTextBuf FdfBuffer;
2495 FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer); 2494 FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer);
2496 delete pFDFDoc; 2495 delete pFDFDoc;
2497 if (!bRet) 2496 if (!bRet)
2498 return FALSE; 2497 return FALSE;
2499 2498
2500 uint8_t* pBuffer = FdfBuffer.GetBuffer(); 2499 uint8_t* pBuffer = FdfBuffer.GetBuffer();
2501 FX_STRSIZE nBufSize = FdfBuffer.GetLength(); 2500 FX_STRSIZE nBufSize = FdfBuffer.GetLength();
2502 2501
2503 if (bUrlEncoded) { 2502 if (bUrlEncoded) {
2504 if (!FDFToURLEncodedData(pBuffer, nBufSize)) 2503 if (!FDFToURLEncodedData(pBuffer, nBufSize))
2505 return FALSE; 2504 return FALSE;
2506 } 2505 }
2507 2506
2508 pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); 2507 pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str());
2509 2508
2510 if (bUrlEncoded) { 2509 if (bUrlEncoded) {
2511 FX_Free(pBuffer); 2510 FX_Free(pBuffer);
2512 pBuffer = NULL; 2511 pBuffer = NULL;
2513 } 2512 }
2514 2513
2515 return TRUE; 2514 return TRUE;
2516 } 2515 }
2517 2516
2518 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) { 2517 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) {
2519 CFDF_Document* pFDF = 2518 CFDF_Document* pFDF =
2520 m_pInterForm->ExportToFDF(m_pDocument->GetPath().AsWideStringC()); 2519 m_pInterForm->ExportToFDF(m_pDocument->GetPath().AsStringC());
2521 if (!pFDF) 2520 if (!pFDF)
2522 return FALSE; 2521 return FALSE;
2523 2522
2524 FX_BOOL bRet = pFDF->WriteBuf(textBuf); 2523 FX_BOOL bRet = pFDF->WriteBuf(textBuf);
2525 delete pFDF; 2524 delete pFDF;
2526 2525
2527 return bRet; 2526 return bRet;
2528 } 2527 }
2529 2528
2530 FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) { 2529 FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2826 break; 2825 break;
2827 } 2826 }
2828 } 2827 }
2829 } 2828 }
2830 2829
2831 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) { 2830 CFX_FloatRect CBA_AnnotIterator::GetAnnotRect(const CPDFSDK_Annot* pAnnot) {
2832 CFX_FloatRect rcAnnot; 2831 CFX_FloatRect rcAnnot;
2833 pAnnot->GetPDFAnnot()->GetRect(rcAnnot); 2832 pAnnot->GetPDFAnnot()->GetRect(rcAnnot);
2834 return rcAnnot; 2833 return rcAnnot;
2835 } 2834 }
OLDNEW
« no previous file with comments | « fpdfsdk/fsdk_baseannot.cpp ('k') | fpdfsdk/fsdk_mgr.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698