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

Side by Side Diff: fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp

Issue 1885973002: Remove implicit cast from CFX_ByteString to (const char*). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Typo 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/fpdfppo.cpp ('k') | fpdfsdk/fsdk_actionhandler.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/fpdfxfa/include/fpdfxfa_doc.h" 7 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h"
8 8
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
(...skipping 21 matching lines...) Expand all
32 #define FXFA_TEMPLATE 0x00000010 32 #define FXFA_TEMPLATE 0x00000010
33 #define FXFA_LOCALESET 0x00000100 33 #define FXFA_LOCALESET 0x00000100
34 #define FXFA_DATASETS 0x00001000 34 #define FXFA_DATASETS 0x00001000
35 #define FXFA_XMPMETA 0x00010000 35 #define FXFA_XMPMETA 0x00010000
36 #define FXFA_XFDF 0x00100000 36 #define FXFA_XFDF 0x00100000
37 #define FXFA_FORM 0x01000000 37 #define FXFA_FORM 0x01000000
38 #define FXFA_PDF 0x10000000 38 #define FXFA_PDF 0x10000000
39 39
40 #ifndef _WIN32 40 #ifndef _WIN32
41 extern void SetLastError(int err); 41 extern void SetLastError(int err);
42
43 extern int GetLastError(); 42 extern int GetLastError();
44 #endif 43 #endif
45 44
46 CPDFXFA_Document::CPDFXFA_Document(CPDF_Document* pPDFDoc, 45 CPDFXFA_Document::CPDFXFA_Document(CPDF_Document* pPDFDoc,
47 CPDFXFA_App* pProvider) 46 CPDFXFA_App* pProvider)
48 : m_iDocType(DOCTYPE_PDF), 47 : m_iDocType(DOCTYPE_PDF),
49 m_pPDFDoc(pPDFDoc), 48 m_pPDFDoc(pPDFDoc),
50 m_pSDKDoc(nullptr), 49 m_pSDKDoc(nullptr),
51 m_pXFADoc(nullptr), 50 m_pXFADoc(nullptr),
52 m_pXFADocView(nullptr), 51 m_pXFADocView(nullptr),
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 bs.ReleaseBuffer(len * sizeof(unsigned short)); 647 bs.ReleaseBuffer(len * sizeof(unsigned short));
649 648
650 if (pFileHandler == NULL) 649 if (pFileHandler == NULL)
651 return; 650 return;
652 651
653 CFPDF_FileStream fileWrite(pFileHandler); 652 CFPDF_FileStream fileWrite(pFileHandler);
654 653
655 CFX_ByteString content; 654 CFX_ByteString content;
656 if (fileType == FXFA_SAVEAS_XML) { 655 if (fileType == FXFA_SAVEAS_XML) {
657 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; 656 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
658 fileWrite.WriteBlock((const FX_CHAR*)content, fileWrite.GetSize(), 657 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(),
659 content.GetLength()); 658 content.GetLength());
660 CFX_WideStringC data(L"data"); 659 CFX_WideStringC data(L"data");
661 if (m_pXFADocView->GetDoc()->SavePackage(data, &fileWrite)) { 660 if (m_pXFADocView->GetDoc()->SavePackage(data, &fileWrite)) {
662 // Ignoring error. 661 // Ignoring error.
663 } 662 }
664 } else if (fileType == FXFA_SAVEAS_XDP) { 663 } else if (fileType == FXFA_SAVEAS_XDP) {
665 if (m_pPDFDoc == NULL) 664 if (m_pPDFDoc == NULL)
666 return; 665 return;
667 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); 666 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot();
668 if (pRoot == NULL) 667 if (pRoot == NULL)
(...skipping 22 matching lines...) Expand all
691 continue; 690 continue;
692 if (pPrePDFObj->GetString() == "form") { 691 if (pPrePDFObj->GetString() == "form") {
693 CFX_WideStringC form(L"form"); 692 CFX_WideStringC form(L"form");
694 m_pXFADocView->GetDoc()->SavePackage(form, &fileWrite); 693 m_pXFADocView->GetDoc()->SavePackage(form, &fileWrite);
695 } else if (pPrePDFObj->GetString() == "datasets") { 694 } else if (pPrePDFObj->GetString() == "datasets") {
696 CFX_WideStringC datasets(L"datasets"); 695 CFX_WideStringC datasets(L"datasets");
697 m_pXFADocView->GetDoc()->SavePackage(datasets, &fileWrite); 696 m_pXFADocView->GetDoc()->SavePackage(datasets, &fileWrite);
698 } else { 697 } else {
699 if (i == size - 1) { 698 if (i == size - 1) {
700 CFX_WideString wPath = CFX_WideString::FromUTF16LE( 699 CFX_WideString wPath = CFX_WideString::FromUTF16LE(
701 (unsigned short*)(const FX_CHAR*)bs, 700 reinterpret_cast<const unsigned short*>(bs.c_str()),
702 bs.GetLength() / sizeof(unsigned short)); 701 bs.GetLength() / sizeof(unsigned short));
703 CFX_ByteString bPath = wPath.UTF8Encode(); 702 CFX_ByteString bPath = wPath.UTF8Encode();
704 CFX_ByteString szFormat = 703 const char* szFormat =
705 "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>"; 704 "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>";
706 content.Format(szFormat, (char*)(const FX_CHAR*)bPath); 705 content.Format(szFormat, bPath.c_str());
707 fileWrite.WriteBlock((const FX_CHAR*)content, fileWrite.GetSize(), 706 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(),
708 content.GetLength()); 707 content.GetLength());
709 } 708 }
710 709
711 CPDF_Stream* pStream = (CPDF_Stream*)pDirectObj; 710 CPDF_Stream* pStream = (CPDF_Stream*)pDirectObj;
712 CPDF_StreamAcc* pAcc = new CPDF_StreamAcc; 711 CPDF_StreamAcc* pAcc = new CPDF_StreamAcc;
713 pAcc->LoadAllData(pStream); 712 pAcc->LoadAllData(pStream);
714 fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(), 713 fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(),
715 pAcc->GetSize()); 714 pAcc->GetSize());
716 delete pAcc; 715 delete pAcc;
717 } 716 }
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 CFX_ByteString content; 946 CFX_ByteString content;
948 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 947 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
949 if (!pEnv) 948 if (!pEnv)
950 return FALSE; 949 return FALSE;
951 950
952 CFPDF_FileStream fileStream(pFileHandler); 951 CFPDF_FileStream fileStream(pFileHandler);
953 952
954 if (fileType == FXFA_SAVEAS_XML) { 953 if (fileType == FXFA_SAVEAS_XML) {
955 CFX_WideString ws; 954 CFX_WideString ws;
956 ws.FromLocal("data"); 955 ws.FromLocal("data");
957 CFX_ByteString content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; 956 const char* content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
958 fileStream.WriteBlock((const FX_CHAR*)content, 0, content.GetLength()); 957 fileStream.WriteBlock(content, 0, strlen(content));
959 m_pXFADoc->SavePackage(ws.AsStringC(), &fileStream); 958 m_pXFADoc->SavePackage(ws.AsStringC(), &fileStream);
960 } else if (fileType == FXFA_SAVEAS_XDP) { 959 } else if (fileType == FXFA_SAVEAS_XDP) {
961 if (flag == 0) 960 if (flag == 0)
962 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | 961 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS |
963 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM; 962 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM;
964 if (m_pPDFDoc == NULL) { 963 if (m_pPDFDoc == NULL) {
965 fileStream.Flush(); 964 fileStream.Flush();
966 return FALSE; 965 return FALSE;
967 } 966 }
968 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); 967 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot();
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 } 1270 }
1272 1271
1273 return _GetHValueByName(szPropName, hValue, 1272 return _GetHValueByName(szPropName, hValue,
1274 m_pSDKDoc->GetEnv()->GetJSRuntime()); 1273 m_pSDKDoc->GetEnv()->GetJSRuntime());
1275 } 1274 }
1276 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name, 1275 FX_BOOL CPDFXFA_Document::_GetHValueByName(const CFX_ByteStringC& utf8Name,
1277 FXJSE_HVALUE hValue, 1276 FXJSE_HVALUE hValue,
1278 IJS_Runtime* runTime) { 1277 IJS_Runtime* runTime) {
1279 return runTime->GetHValueByName(utf8Name, hValue); 1278 return runTime->GetHValueByName(utf8Name, hValue);
1280 } 1279 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfppo.cpp ('k') | fpdfsdk/fsdk_actionhandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698