summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-11-20 14:55:19 -0800
committerTom Sepez <tsepez@chromium.org>2015-11-20 14:55:19 -0800
commit87d7b4fc58b4ec5fe097de5862490c5720c3ec09 (patch)
treed1f71eee62f3a2c602a29c3fa95dece9d668d72d /core
parentb8ec0a3405c6f184e4b9811870081295cae078c9 (diff)
downloadpdfium-87d7b4fc58b4ec5fe097de5862490c5720c3ec09.tar.xz
Make XFA core/ look like master (part N).
R=thestig@chromium.org Review URL: https://codereview.chromium.org/1463173003 .
Diffstat (limited to 'core')
-rw-r--r--core/include/fpdfapi/fpdf_parser.h9
-rw-r--r--core/include/fpdftext/fpdf_text.h4
-rw-r--r--core/include/fxge/fx_font.h1
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp103
-rw-r--r--core/src/fpdftext/fpdf_text_int.cpp40
-rw-r--r--core/src/fpdftext/text_int.h5
-rw-r--r--core/src/fxge/win32/fx_win32_print.cpp2
7 files changed, 59 insertions, 105 deletions
diff --git a/core/include/fpdfapi/fpdf_parser.h b/core/include/fpdfapi/fpdf_parser.h
index 3d10726a4e..efb955be21 100644
--- a/core/include/fpdfapi/fpdf_parser.h
+++ b/core/include/fpdfapi/fpdf_parser.h
@@ -11,7 +11,6 @@
#include "core/include/fxcrt/fx_system.h"
#include "fpdf_objects.h"
-#include "public/fpdf_dataavail.h"
#include "third_party/base/nonstd_unique_ptr.h"
class CFDF_Document;
@@ -912,19 +911,19 @@ class IPDF_DataAvail {
FormNotExist = 2, // PDF_FORM_NOTEXIST
};
-static IPDF_DataAvail* Create(IFX_FileAvail* pFileAvail,
+ static IPDF_DataAvail* Create(IFX_FileAvail* pFileAvail,
IFX_FileRead* pFileRead);
virtual ~IPDF_DataAvail() {}
IFX_FileAvail* GetFileAvail() const { return m_pFileAvail; }
IFX_FileRead* GetFileRead() const { return m_pFileRead; }
- virtual int IsDocAvail(IFX_DownloadHints* pHints) = 0;
+ virtual DocAvailStatus IsDocAvail(IFX_DownloadHints* pHints) = 0;
virtual void SetDocument(CPDF_Document* pDoc) = 0;
virtual int IsPageAvail(int iPage, IFX_DownloadHints* pHints) = 0;
virtual FX_BOOL IsLinearized() = 0;
- virtual int IsFormAvail(IFX_DownloadHints* pHints) = 0;
- virtual int IsLinearizedPDF() = 0;
+ virtual DocFormStatus IsFormAvail(IFX_DownloadHints* pHints) = 0;
+ virtual DocLinearizationStatus IsLinearizedPDF() = 0;
virtual void GetLinearizedMainXRefInfo(FX_FILESIZE* pPos,
FX_DWORD* pSize) = 0;
diff --git a/core/include/fpdftext/fpdf_text.h b/core/include/fpdftext/fpdf_text.h
index 1671861fbb..360e256ce6 100644
--- a/core/include/fpdftext/fpdf_text.h
+++ b/core/include/fpdftext/fpdf_text.h
@@ -76,10 +76,6 @@ class CPDFText_ParseOptions {
class IPDF_TextPage {
public:
static IPDF_TextPage* CreateTextPage(const CPDF_Page* pPage, int flags = 0);
- static IPDF_TextPage* CreateTextPage(const CPDF_Page* pPage,
- CPDFText_ParseOptions ParserOptions);
- static IPDF_TextPage* CreateTextPage(const CPDF_PageObjects* pObjs,
- int flags = 0);
static IPDF_TextPage* CreateReflowTextPage(IPDF_ReflowedPage* pRefPage);
virtual ~IPDF_TextPage() {}
diff --git a/core/include/fxge/fx_font.h b/core/include/fxge/fx_font.h
index 42b0e902c6..d2b1d5459a 100644
--- a/core/include/fxge/fx_font.h
+++ b/core/include/fxge/fx_font.h
@@ -373,7 +373,6 @@ class CFX_FolderFontInfo : public IFX_SystemFontInfo {
public:
CFX_FolderFontInfo();
~CFX_FolderFontInfo() override;
-
void AddPath(const CFX_ByteStringC& path);
// IFX_SytemFontInfo:
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index b55ce64a23..2105635687 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -2680,13 +2680,14 @@ class CPDF_DataAvail final : public IPDF_DataAvail {
~CPDF_DataAvail() override;
// IPDF_DataAvail:
- int IsDocAvail(IFX_DownloadHints* pHints) override;
+ DocAvailStatus IsDocAvail(IFX_DownloadHints* pHints) override;
void SetDocument(CPDF_Document* pDoc) override;
int IsPageAvail(int iPage, IFX_DownloadHints* pHints) override;
- int IsFormAvail(IFX_DownloadHints* pHints) override;
- int IsLinearizedPDF() override;
+ DocFormStatus IsFormAvail(IFX_DownloadHints* pHints) override;
+ DocLinearizationStatus IsLinearizedPDF() override;
FX_BOOL IsLinearized() override { return m_bLinearized; }
void GetLinearizedMainXRefInfo(FX_FILESIZE* pPos, FX_DWORD* pSize) override;
+
int GetPageCount() const;
CPDF_Dictionary* GetPage(int index);
@@ -3076,20 +3077,23 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail(CFX_PtrArray& obj_array,
obj_array.Append(new_obj_array);
return IsObjectsAvail(obj_array, FALSE, pHints, ret_array);
}
-int CPDF_DataAvail::IsDocAvail(IFX_DownloadHints* pHints) {
+
+IPDF_DataAvail::DocAvailStatus CPDF_DataAvail::IsDocAvail(
+ IFX_DownloadHints* pHints) {
if (!m_dwFileLen && m_pFileRead) {
m_dwFileLen = (FX_DWORD)m_pFileRead->GetSize();
if (!m_dwFileLen) {
- return PDF_DATA_ERROR;
+ return DataError;
}
}
while (!m_bDocAvail) {
if (!CheckDocStatus(pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
}
- return PDF_DATA_AVAIL;
+ return DataAvailable;
}
+
FX_BOOL CPDF_DataAvail::CheckAcroFormSubObject(IFX_DownloadHints* pHints) {
if (!m_objs_array.GetSize()) {
m_objs_array.RemoveAll();
@@ -3640,24 +3644,24 @@ CPDF_Object* CPDF_DataAvail::ParseIndirectObjectAt(
m_syntaxParser.RestorePos(SavedPos);
return pObj;
}
-int CPDF_DataAvail::IsLinearizedPDF() {
+IPDF_DataAvail::DocLinearizationStatus CPDF_DataAvail::IsLinearizedPDF() {
FX_DWORD req_size = 1024;
if (!m_pFileAvail->IsDataAvail(0, req_size)) {
- return PDF_LINEARIZATION_UNKNOWN;
+ return LinearizationUnknown;
}
if (!m_pFileRead) {
- return PDF_NOT_LINEARIZED;
+ return NotLinearized;
}
FX_FILESIZE dwSize = m_pFileRead->GetSize();
if (dwSize < (FX_FILESIZE)req_size) {
- return PDF_LINEARIZATION_UNKNOWN;
+ return LinearizationUnknown;
}
uint8_t buffer[1024];
m_pFileRead->ReadBlock(buffer, 0, req_size);
if (IsLinearizedFile(buffer, req_size)) {
- return PDF_LINEARIZED;
+ return Linearized;
}
- return PDF_NOT_LINEARIZED;
+ return NotLinearized;
}
FX_BOOL CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, FX_DWORD dwLen) {
ScopedFileStream file(FX_CreateMemoryStream(pData, (size_t)dwLen, FALSE));
@@ -4274,33 +4278,33 @@ FX_BOOL CPDF_DataAvail::LoadPages(IFX_DownloadHints* pHints) {
}
int CPDF_DataAvail::CheckLinearizedData(IFX_DownloadHints* pHints) {
if (m_bLinearedDataOK) {
- return PDF_DATA_AVAIL;
+ return DataAvailable;
}
if (!m_bMainXRefLoadTried) {
FX_SAFE_DWORD data_size = m_dwFileLen;
data_size -= m_dwLastXRefOffset;
if (!data_size.IsValid()) {
- return PDF_DATA_ERROR;
+ return DataError;
}
if (!m_pFileAvail->IsDataAvail(m_dwLastXRefOffset,
data_size.ValueOrDie())) {
pHints->AddSegment(m_dwLastXRefOffset, data_size.ValueOrDie());
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
FX_DWORD dwRet = (m_pDocument->GetParser())->LoadLinearizedMainXRefTable();
m_bMainXRefLoadTried = TRUE;
if (dwRet != PDFPARSE_ERROR_SUCCESS) {
- return PDF_DATA_ERROR;
+ return DataError;
}
if (!PreparePageItem()) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
m_bMainXRefLoadedOK = TRUE;
m_bLinearedDataOK = TRUE;
}
- return m_bLinearedDataOK ? PDF_DATA_AVAIL : PDF_DATA_NOTAVAIL;
+ return m_bLinearedDataOK ? DataAvailable : DataNotAvailable;
}
FX_BOOL CPDF_DataAvail::CheckPageAnnots(int32_t iPage,
IFX_DownloadHints* pHints) {
@@ -4368,7 +4372,7 @@ FX_BOOL CPDF_DataAvail::HaveResourceAncestor(CPDF_Dictionary* pDict) {
}
int CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) {
if (!m_pDocument) {
- return PDF_DATA_ERROR;
+ return DataError;
}
if (IsFirstCheck(iPage)) {
m_bCurPageDictLoadOK = FALSE;
@@ -4379,52 +4383,52 @@ int CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) {
m_objnum_array.RemoveAll();
}
if (m_pagesLoadState.find(iPage) != m_pagesLoadState.end()) {
- return PDF_DATA_AVAIL;
+ return DataAvailable;
}
if (m_bLinearized) {
if ((FX_DWORD)iPage == m_dwFirstPageNo) {
m_pagesLoadState.insert(iPage);
- return PDF_DATA_AVAIL;
+ return DataAvailable;
}
int32_t nResult = CheckLinearizedData(pHints);
- if (nResult != PDF_DATA_AVAIL) {
+ if (nResult != DataAvailable) {
return nResult;
}
if (m_pHintTables) {
nResult = m_pHintTables->CheckPage(iPage, pHints);
- if (nResult != PDF_DATA_AVAIL)
+ if (nResult != DataAvailable)
return nResult;
m_pagesLoadState.insert(iPage);
- return PDF_DATA_AVAIL;
+ return DataAvailable;
}
if (m_bMainXRefLoadedOK) {
if (m_bTotalLoadPageTree) {
if (!LoadPages(pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
} else {
if (!m_bCurPageDictLoadOK && !CheckPage(iPage, pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
}
} else {
if (!LoadAllFile(pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
((CPDF_Parser*)m_pDocument->GetParser())->RebuildCrossRef();
ResetFirstCheck(iPage);
- return PDF_DATA_AVAIL;
+ return DataAvailable;
}
} else {
if (!m_bTotalLoadPageTree) {
if (!m_bCurPageDictLoadOK && !CheckPage(iPage, pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
}
}
if (m_bHaveAcroForm && !m_bAcroFormLoad) {
if (!CheckAcroFormSubObject(pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
m_bAcroFormLoad = TRUE;
}
@@ -4435,7 +4439,7 @@ int CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) {
m_pPageDict = m_pDocument->GetPage(iPage);
if (!m_pPageDict) {
ResetFirstCheck(iPage);
- return PDF_DATA_AVAIL;
+ return DataAvailable;
}
CFX_PtrArray obj_array;
obj_array.Add(m_pPageDict);
@@ -4455,14 +4459,14 @@ int CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) {
m_bPageLoadedOK = TRUE;
} else {
m_objs_array.Append(new_objs_array);
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
}
}
if (m_bPageLoadedOK) {
if (!m_bAnnotsLoad) {
if (!CheckPageAnnots(iPage, pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
m_bAnnotsLoad = TRUE;
}
@@ -4478,7 +4482,7 @@ int CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) {
if (m_bNeedDownLoadResource) {
FX_BOOL bRet = CheckResources(pHints);
if (!bRet) {
- return PDF_DATA_NOTAVAIL;
+ return DataNotAvailable;
}
m_bNeedDownLoadResource = FALSE;
}
@@ -4487,7 +4491,7 @@ int CPDF_DataAvail::IsPageAvail(int32_t iPage, IFX_DownloadHints* pHints) {
m_bCurPageDictLoadOK = FALSE;
ResetFirstCheck(iPage);
m_pagesLoadState.insert(iPage);
- return PDF_DATA_AVAIL;
+ return DataAvailable;
}
FX_BOOL CPDF_DataAvail::CheckResources(IFX_DownloadHints* pHints) {
if (!m_objs_array.GetSize()) {
@@ -4553,21 +4557,22 @@ CPDF_Dictionary* CPDF_DataAvail::GetPage(int index) {
}
return m_pDocument->GetPage(index);
}
-int CPDF_DataAvail::IsFormAvail(IFX_DownloadHints* pHints) {
+IPDF_DataAvail::DocFormStatus CPDF_DataAvail::IsFormAvail(
+ IFX_DownloadHints* pHints) {
if (!m_pDocument) {
- return PDF_FORM_AVAIL;
+ return FormAvailable;
}
if (!m_bLinearizedFormParamLoad) {
CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
if (!pRoot) {
- return PDF_FORM_AVAIL;
+ return FormAvailable;
}
CPDF_Object* pAcroForm = pRoot->GetElement(FX_BSTRC("AcroForm"));
if (!pAcroForm) {
- return PDF_FORM_NOTEXIST;
+ return FormNotExist;
}
if (!CheckLinearizedData(pHints)) {
- return PDF_FORM_NOTAVAIL;
+ return FormNotAvailable;
}
if (!m_objs_array.GetSize()) {
m_objs_array.Add(pAcroForm->GetDict());
@@ -4579,9 +4584,9 @@ int CPDF_DataAvail::IsFormAvail(IFX_DownloadHints* pHints) {
m_objs_array.RemoveAll();
if (!bRet) {
m_objs_array.Append(new_objs_array);
- return PDF_FORM_NOTAVAIL;
+ return FormNotAvailable;
}
- return PDF_FORM_AVAIL;
+ return FormAvailable;
}
void CPDF_SortObjNumArray::AddObjNum(FX_DWORD dwObjNum) {
int32_t iNext = 0;
@@ -4865,17 +4870,17 @@ FX_BOOL CPDF_HintTables::GetPagePos(int index,
}
int32_t CPDF_HintTables::CheckPage(int index, IFX_DownloadHints* pHints) {
if (!m_pLinearizedDict || !pHints)
- return PDF_DATA_ERROR;
+ return IPDF_DataAvail::DataError;
CPDF_Object* pFirstAvailPage =
m_pLinearizedDict->GetElementValue(FX_BSTRC("P"));
int nFirstAvailPage = pFirstAvailPage ? pFirstAvailPage->GetInteger() : 0;
if (index == nFirstAvailPage)
- return PDF_DATA_AVAIL;
+ return IPDF_DataAvail::DataAvailable;
FX_DWORD dwLength = GetItemLength(index, m_szPageOffsetArray);
if (!dwLength ||
!m_pDataAvail->IsDataAvail(m_szPageOffsetArray[index], dwLength,
pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return IPDF_DataAvail::DataNotAvailable;
}
// Download data of shared objects in the page.
FX_DWORD offset = 0;
@@ -4886,7 +4891,7 @@ int32_t CPDF_HintTables::CheckPage(int index, IFX_DownloadHints* pHints) {
m_pLinearizedDict->GetElementValue(FX_BSTRC("O"));
int nFirstPageObjNum = pFirstPageObj ? pFirstPageObj->GetInteger() : -1;
if (nFirstPageObjNum < 0)
- return FALSE;
+ return FALSE; // TODO(thestig): Fix this and the return type.
FX_DWORD dwIndex = 0;
FX_DWORD dwObjNum = 0;
for (int j = 0; j < m_dwNSharedObjsArray[index]; ++j) {
@@ -4900,10 +4905,10 @@ int32_t CPDF_HintTables::CheckPage(int index, IFX_DownloadHints* pHints) {
if (!dwLength ||
!m_pDataAvail->IsDataAvail(m_szSharedObjOffsetArray[dwIndex], dwLength,
pHints)) {
- return PDF_DATA_NOTAVAIL;
+ return IPDF_DataAvail::DataNotAvailable;
}
}
- return PDF_DATA_AVAIL;
+ return IPDF_DataAvail::DataAvailable;
}
FX_BOOL CPDF_HintTables::LoadHintStream(CPDF_Stream* pHintStream) {
if (!pHintStream || !m_pLinearizedDict)
diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp
index d467fb91e0..3342f38da9 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -83,22 +83,11 @@ CPDFText_ParseOptions::CPDFText_ParseOptions()
m_bNormalizeObjs(TRUE),
m_bOutputHyphen(FALSE) {}
-IPDF_TextPage* IPDF_TextPage::CreateTextPage(
- const CPDF_Page* pPage,
- CPDFText_ParseOptions ParserOptions) {
- return new CPDF_TextPage(pPage, ParserOptions);
-}
-
IPDF_TextPage* IPDF_TextPage::CreateTextPage(const CPDF_Page* pPage,
int flags) {
return new CPDF_TextPage(pPage, flags);
}
-IPDF_TextPage* IPDF_TextPage::CreateTextPage(const CPDF_PageObjects* pObjs,
- int flags) {
- return new CPDF_TextPage(pObjs, flags);
-}
-
IPDF_TextPageFind* IPDF_TextPageFind::CreatePageFind(
const IPDF_TextPage* pTextPage) {
return pTextPage ? new CPDF_TextPageFind(pTextPage) : nullptr;
@@ -131,35 +120,6 @@ CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage, int flags)
(int)pPage->GetPageHeight(), 0);
}
-CPDF_TextPage::CPDF_TextPage(const CPDF_Page* pPage,
- CPDFText_ParseOptions ParserOptions)
- : m_ParseOptions(ParserOptions),
- m_pPage(pPage),
- m_charList(512),
- m_TempCharList(50),
- m_parserflag(0),
- m_pPreTextObj(nullptr),
- m_bIsParsed(false),
- m_TextlineDir(-1),
- m_CurlineRect(0, 0, 0, 0) {
- m_TextBuf.EstimateSize(0, 10240);
- pPage->GetDisplayMatrix(m_DisplayMatrix, 0, 0, (int)pPage->GetPageWidth(),
- (int)pPage->GetPageHeight(), 0);
-}
-
-CPDF_TextPage::CPDF_TextPage(const CPDF_PageObjects* pPage, int flags)
- : m_pPage(pPage),
- m_charList(512),
- m_TempCharList(50),
- m_parserflag(flags),
- m_pPreTextObj(nullptr),
- m_bIsParsed(false),
- m_TextlineDir(-1),
- m_CurlineRect(0, 0, 0, 0) {
- m_TextBuf.EstimateSize(0, 10240);
- CFX_FloatRect pageRect = pPage->CalcBoundingBox();
- m_DisplayMatrix = CFX_AffineMatrix(1, 0, 0, -1, pageRect.right, pageRect.top);
-}
void CPDF_TextPage::NormalizeObjects(FX_BOOL bNormalize) {
m_ParseOptions.m_bNormalizeObjs = bNormalize;
}
diff --git a/core/src/fpdftext/text_int.h b/core/src/fpdftext/text_int.h
index 46249150ce..da4bf70ad1 100644
--- a/core/src/fpdftext/text_int.h
+++ b/core/src/fpdftext/text_int.h
@@ -8,7 +8,6 @@
#define CORE_SRC_FPDFTEXT_TEXT_INT_H_
#include "core/include/fpdftext/fpdf_text.h"
-#include "core/include/fxcrt/fx_arb.h"
#include "core/include/fxcrt/fx_basic.h"
class CFX_BidiChar;
@@ -52,9 +51,7 @@ typedef CFX_ArrayTemplate<PDFTEXT_Obj> LINEOBJ;
class CPDF_TextPage : public IPDF_TextPage {
public:
- CPDF_TextPage(const CPDF_Page* pPage, int flags = 0);
- CPDF_TextPage(const CPDF_PageObjects* pPage, int flags = 0);
- CPDF_TextPage(const CPDF_Page* pPage, CPDFText_ParseOptions ParserOptions);
+ CPDF_TextPage(const CPDF_Page* pPage, int flags);
~CPDF_TextPage() override {}
// IPDF_TextPage
diff --git a/core/src/fxge/win32/fx_win32_print.cpp b/core/src/fxge/win32/fx_win32_print.cpp
index cb7b590f7c..126e5d7f47 100644
--- a/core/src/fxge/win32/fx_win32_print.cpp
+++ b/core/src/fxge/win32/fx_win32_print.cpp
@@ -140,8 +140,6 @@ static CFX_DIBitmap* Transform1bppBitmap(const CFX_DIBSource* pSrc,
ASSERT(pSrc->GetFormat() == FXDIB_1bppRgb ||
pSrc->GetFormat() == FXDIB_1bppMask ||
pSrc->GetFormat() == FXDIB_1bppCmyk);
- CFX_FloatRect unit_rect = pDestMatrix->GetUnitRect();
- FX_RECT full_rect = unit_rect.GetOutterRect();
CFX_DIBExtractor src_bitmap(pSrc);
CFX_DIBitmap* pSrcBitmap = src_bitmap;
if (pSrcBitmap == NULL) {