From 11d93559cea7a0894e05249e7dac2035ad79994e Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 9 Feb 2016 09:55:54 -0800 Subject: Banish CFX_WordArray to XFA-land. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1676913004 . --- fpdfsdk/include/fsdk_mgr.h | 7 ++++--- fpdfsdk/src/fpdfppo.cpp | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 14 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h index 2df44c7ca1..bef3b980fe 100644 --- a/fpdfsdk/include/fsdk_mgr.h +++ b/fpdfsdk/include/fsdk_mgr.h @@ -9,6 +9,7 @@ #include #include +#include #include "core/include/fpdftext/fpdf_text.h" #include "fsdk_actionhandler.h" @@ -519,14 +520,14 @@ class CPDFSDK_Document { FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0); FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0); - FX_BOOL ExtractPages(const CFX_WordArray& arrExtraPages, + FX_BOOL ExtractPages(const std::vector& arrExtraPages, CPDF_Document* pDstDoc); FX_BOOL InsertPages(int nInsertAt, const CPDF_Document* pSrcDoc, - const CFX_WordArray& arrSrcPages); + const std::vector& arrSrcPages); FX_BOOL ReplacePages(int nPage, const CPDF_Document* pSrcDoc, - const CFX_WordArray& arrSrcPages); + const std::vector& arrSrcPages); void OnCloseDocument(); diff --git a/fpdfsdk/src/fpdfppo.cpp b/fpdfsdk/src/fpdfppo.cpp index c05c7f35f0..84ac41d60e 100644 --- a/fpdfsdk/src/fpdfppo.cpp +++ b/fpdfsdk/src/fpdfppo.cpp @@ -9,6 +9,7 @@ #include #include "fpdfsdk/include/fsdk_define.h" +#include "third_party/base/stl_util.h" class CPDF_PageOrganizer { public: @@ -18,7 +19,7 @@ class CPDF_PageOrganizer { FX_BOOL PDFDocInit(CPDF_Document* pDestPDFDoc, CPDF_Document* pSrcPDFDoc); FX_BOOL ExportPage(CPDF_Document* pSrcPDFDoc, - CFX_WordArray* nPageNum, + std::vector* pPageNums, CPDF_Document* pDestPDFDoc, int nIndex); CPDF_Object* PageDictGetInheritableTag(CPDF_Dictionary* pDict, @@ -87,16 +88,15 @@ FX_BOOL CPDF_PageOrganizer::PDFDocInit(CPDF_Document* pDestPDFDoc, } FX_BOOL CPDF_PageOrganizer::ExportPage(CPDF_Document* pSrcPDFDoc, - CFX_WordArray* nPageNum, + std::vector* pPageNums, CPDF_Document* pDestPDFDoc, int nIndex) { int curpage = nIndex; - std::unique_ptr pObjNumberMap(new ObjectNumberMap); - - for (int i = 0; i < nPageNum->GetSize(); ++i) { + int nSize = pdfium::CollectionSize(*pPageNums); + for (int i = 0; i < nSize; ++i) { CPDF_Dictionary* pCurPageDict = pDestPDFDoc->CreateNewPage(curpage); - CPDF_Dictionary* pSrcPageDict = pSrcPDFDoc->GetPage(nPageNum->GetAt(i) - 1); + CPDF_Dictionary* pSrcPageDict = pSrcPDFDoc->GetPage(pPageNums->at(i) - 1); if (!pSrcPageDict || !pCurPageDict) return FALSE; @@ -306,7 +306,7 @@ FX_DWORD CPDF_PageOrganizer::GetNewObjId(CPDF_Document* pDoc, } FPDF_BOOL ParserPageRangeString(CFX_ByteString rangstring, - CFX_WordArray* pageArray, + std::vector* pageArray, int nCount) { if (rangstring.GetLength() != 0) { rangstring.Remove(' '); @@ -329,7 +329,7 @@ FPDF_BOOL ParserPageRangeString(CFX_ByteString rangstring, long lPageNum = atol(cbMidRange); if (lPageNum <= 0 || lPageNum > nCount) return FALSE; - pageArray->Add((FX_WORD)lPageNum); + pageArray->push_back((FX_WORD)lPageNum); } else { int nStartPageNum = atol(cbMidRange.Mid(0, nMid)); if (nStartPageNum == 0) @@ -346,7 +346,7 @@ FPDF_BOOL ParserPageRangeString(CFX_ByteString rangstring, return FALSE; } for (int i = nStartPageNum; i <= nEndPageNum; ++i) { - pageArray->Add(i); + pageArray->push_back(i); } } nStringFrom = nStringTo + 1; @@ -367,14 +367,14 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc, if (!pSrcDoc) return FALSE; - CFX_WordArray pageArray; + std::vector pageArray; int nCount = pSrcDoc->GetPageCount(); if (pagerange) { if (!ParserPageRangeString(pagerange, &pageArray, nCount)) return FALSE; } else { for (int i = 1; i <= nCount; ++i) { - pageArray.Add(i); + pageArray.push_back(i); } } -- cgit v1.2.3