summaryrefslogtreecommitdiff
path: root/core/src/fpdfdoc/doc_ap.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-07-23 13:36:00 -0700
committerTom Sepez <tsepez@chromium.org>2015-07-23 13:36:00 -0700
commitf1e7c461dfabbff6b65a072f24f6711b34159361 (patch)
tree3b0bb772a59669f06b86824a444fd06642592d4b /core/src/fpdfdoc/doc_ap.cpp
parent320b2313d19869333ed453af546e61a9fc2b81c9 (diff)
downloadpdfium-f1e7c461dfabbff6b65a072f24f6711b34159361.tar.xz
Revert "FX_BOOL considered harmful, part 2."
This reverts commit 320b2313d19869333ed453af546e61a9fc2b81c9. Reason for revert: build failure. TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1255693002 .
Diffstat (limited to 'core/src/fpdfdoc/doc_ap.cpp')
-rw-r--r--core/src/fpdfdoc/doc_ap.cpp96
1 files changed, 48 insertions, 48 deletions
diff --git a/core/src/fpdfdoc/doc_ap.cpp b/core/src/fpdfdoc/doc_ap.cpp
index 4f3f178007..f94a4d60e0 100644
--- a/core/src/fpdfdoc/doc_ap.cpp
+++ b/core/src/fpdfdoc/doc_ap.cpp
@@ -8,10 +8,10 @@
#include "../../include/fpdfdoc/fpdf_vt.h"
#include "pdf_vt.h"
#include "../../include/fpdfdoc/fpdf_ap.h"
-bool FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict)
+FX_BOOL FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict)
{
if (!pAnnotDict || pAnnotDict->GetConstString("Subtype") != FX_BSTRC("Widget")) {
- return false;
+ return FALSE;
}
CFX_ByteString field_type = FPDF_GetFieldAttr(pAnnotDict, "FT")->GetString();
FX_DWORD flags = FPDF_GetFieldAttr(pAnnotDict, "Ff")? FPDF_GetFieldAttr(pAnnotDict, "Ff")->GetInteger() : 0;
@@ -34,7 +34,7 @@ bool FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict)
}
}
}
- return false;
+ return FALSE;
}
class CPVT_FontMap : public IPVT_FontMap
{
@@ -154,12 +154,12 @@ int32_t CPVT_Provider::GetWordFontIndex(FX_WORD word, int32_t charset, int32_t n
}
return -1;
}
-bool CPVT_Provider::IsLatinWord(FX_WORD word)
+FX_BOOL CPVT_Provider::IsLatinWord(FX_WORD word)
{
if ((word >= 0x61 && word <= 0x7A) || (word >= 0x41 && word <= 0x5A) || word == 0x2D || word == 0x27) {
- return true;
+ return TRUE;
}
- return false;
+ return FALSE;
}
int32_t CPVT_Provider::GetDefaultFontIndex()
{
@@ -244,14 +244,14 @@ static CPVT_Color ParseColor(const CPDF_Array & array)
}
return rt;
}
-static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, const int32_t & nWidgetType)
+static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, const int32_t & nWidgetType)
{
CPDF_Dictionary* pFormDict = NULL;
if (CPDF_Dictionary * pRootDict = pDoc->GetRoot()) {
pFormDict = pRootDict->GetDict("AcroForm");
}
if (!pFormDict) {
- return false;
+ return FALSE;
}
CFX_ByteString DA;
if (CPDF_Object* pDAObj = FPDF_GetFieldAttr(pAnnotDict, "DA")) {
@@ -261,23 +261,23 @@ static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, c
DA = pFormDict->GetString("DA");
}
if (DA.IsEmpty()) {
- return false;
+ return FALSE;
}
CPDF_SimpleParser syntax(DA);
syntax.FindTagParam("Tf", 2);
CFX_ByteString sFontName = syntax.GetWord();
sFontName = PDF_NameDecode(sFontName);
if (sFontName.IsEmpty()) {
- return false;
+ return FALSE;
}
FX_FLOAT fFontSize = FX_atof(syntax.GetWord());
CPVT_Color crText = ParseColor(DA);
- bool bUseFormRes = false;
+ FX_BOOL bUseFormRes = FALSE;
CPDF_Dictionary * pFontDict = NULL;
CPDF_Dictionary* pDRDict = pAnnotDict->GetDict(FX_BSTRC("DR"));
if (pDRDict == NULL) {
pDRDict = pFormDict->GetDict(FX_BSTRC("DR"));
- bUseFormRes = true;
+ bUseFormRes = TRUE;
}
CPDF_Dictionary * pDRFontDict = NULL;
if (pDRDict && (pDRFontDict = pDRDict->GetDict("Font"))) {
@@ -291,12 +291,12 @@ static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, c
}
}
if (!pDRFontDict) {
- return false;
+ return FALSE;
}
if (!pFontDict) {
pFontDict = CPDF_Dictionary::Create();
if (pFontDict == NULL) {
- return false;
+ return FALSE;
}
pFontDict->SetAtName(FX_BSTRC("Type"), "Font");
pFontDict->SetAtName(FX_BSTRC("Subtype"), "Type1");
@@ -307,7 +307,7 @@ static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, c
}
CPDF_Font* pDefFont = pDoc->LoadFont(pFontDict);
if (!pDefFont) {
- return false;
+ return FALSE;
}
CPDF_Rect rcAnnot = pAnnotDict->GetRect("Rect");
int32_t nRotate = 0;
@@ -378,7 +378,7 @@ static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, c
}
}
CFX_ByteTextBuf sAppStream;
- CFX_ByteString sBG = CPVT_GenerateAP::GenerateColorAP(crBG, true);
+ CFX_ByteString sBG = CPVT_GenerateAP::GenerateColorAP(crBG, TRUE);
if (sBG.GetLength() > 0) {
sAppStream << "q\n" << sBG << rcBBox.left << " " << rcBBox.bottom << " "
<< rcBBox.Width() << " " << rcBBox.Height() << " re f\n" << "Q\n";
@@ -395,7 +395,7 @@ static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, c
if (pAPDict == NULL) {
pAPDict = CPDF_Dictionary::Create();
if (pAPDict == NULL) {
- return false;
+ return FALSE;
}
pAnnotDict->SetAt("AP", pAPDict);
}
@@ -403,7 +403,7 @@ static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, c
if (pNormalStream == NULL) {
pNormalStream = CPDF_Stream::Create(NULL, 0, NULL);
if (pNormalStream == NULL) {
- return false;
+ return FALSE;
}
int32_t objnum = pDoc->AddIndirectObject(pNormalStream);
pAnnotDict->GetDict("AP")->SetAtReference("N", pDoc, objnum);
@@ -418,7 +418,7 @@ static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, c
if (!pStreamResFontList) {
pStreamResFontList = CPDF_Dictionary::Create();
if (pStreamResFontList == NULL) {
- return false;
+ return FALSE;
}
pStreamResList->SetAt("Font", pStreamResFontList);
}
@@ -443,21 +443,21 @@ static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, c
vt.SetPlateRect(rcBody);
vt.SetAlignment(nAlign);
if (IsFloatZero(fFontSize)) {
- vt.SetAutoFontSize(true);
+ vt.SetAutoFontSize(TRUE);
} else {
vt.SetFontSize(fFontSize);
}
- bool bMultiLine = (dwFlags >> 12) & 1;
+ FX_BOOL bMultiLine = (dwFlags >> 12) & 1;
if (bMultiLine) {
- vt.SetMultiLine(true);
- vt.SetAutoReturn(true);
+ vt.SetMultiLine(TRUE);
+ vt.SetAutoReturn(TRUE);
}
FX_WORD subWord = 0;
if ((dwFlags >> 13) & 1) {
subWord = '*';
vt.SetPasswordChar(subWord);
}
- bool bCharArray = (dwFlags >> 24) & 1;
+ FX_BOOL bCharArray = (dwFlags >> 24) & 1;
if (bCharArray) {
vt.SetCharArray(dwMaxLen);
} else {
@@ -479,7 +479,7 @@ static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, c
sAppStream << rcBody.left << " " << rcBody.bottom << " "
<< rcBody.Width() << " " << rcBody.Height() << " re\nW\nn\n";
}
- sAppStream << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, true) << sBody << "ET\n" << "Q\nEMC\n";
+ sAppStream << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE) << sBody << "ET\n" << "Q\nEMC\n";
}
}
break;
@@ -497,7 +497,7 @@ static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, c
rcEdit.Normalize();
vt.SetPlateRect(rcEdit);
if (IsFloatZero(fFontSize)) {
- vt.SetAutoFontSize(true);
+ vt.SetAutoFontSize(TRUE);
} else {
vt.SetFontSize(fFontSize);
}
@@ -506,14 +506,14 @@ static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, c
vt.RearrangeAll();
CPDF_Rect rcContent = vt.GetContentRect();
CPDF_Point ptOffset = CPDF_Point(0.0f, (rcContent.Height() - rcEdit.Height()) / 2.0f);
- CFX_ByteString sEdit = CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), ptOffset, true, 0);
+ CFX_ByteString sEdit = CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), ptOffset, TRUE, 0);
if (sEdit.GetLength() > 0) {
sAppStream << "/Tx BMC\n" << "q\n";
sAppStream << rcEdit.left << " " << rcEdit.bottom << " "
<< rcEdit.Width() << " " << rcEdit.Height() << " re\nW\nn\n";
- sAppStream << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, true) << sEdit << "ET\n" << "Q\nEMC\n";
+ sAppStream << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE) << sEdit << "ET\n" << "Q\nEMC\n";
}
- CFX_ByteString sButton = CPVT_GenerateAP::GenerateColorAP(CPVT_Color(CT_RGB, 220.0f / 255.0f, 220.0f / 255.0f, 220.0f / 255.0f), true);
+ CFX_ByteString sButton = CPVT_GenerateAP::GenerateColorAP(CPVT_Color(CT_RGB, 220.0f / 255.0f, 220.0f / 255.0f, 220.0f / 255.0f), TRUE);
if (sButton.GetLength() > 0 && !rcButton.IsEmpty()) {
sAppStream << "q\n" << sButton;
sAppStream << rcButton.left << " " << rcButton.bottom << " "
@@ -555,11 +555,11 @@ static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, c
} else if (pOpt->GetType() == PDFOBJ_ARRAY) {
swItem = ((CPDF_Array*)pOpt)->GetElementValue(1)->GetUnicodeText();
}
- bool bSelected = false;
+ FX_BOOL bSelected = FALSE;
if (pSels) {
for (FX_DWORD s = 0, ssz = pSels->GetCount(); s < ssz; s++) {
if (i == pSels->GetInteger(s)) {
- bSelected = true;
+ bSelected = TRUE;
break;
}
}
@@ -578,11 +578,11 @@ static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, c
FX_FLOAT fItemHeight = vt.GetContentRect().Height();
if (bSelected) {
CPDF_Rect rcItem = CPDF_Rect(rcBody.left, fy - fItemHeight, rcBody.right, fy);
- sBody << "q\n" << CPVT_GenerateAP::GenerateColorAP(CPVT_Color(CT_RGB, 0, 51.0f / 255.0f, 113.0f / 255.0f), true)
+ sBody << "q\n" << CPVT_GenerateAP::GenerateColorAP(CPVT_Color(CT_RGB, 0, 51.0f / 255.0f, 113.0f / 255.0f), TRUE)
<< rcItem.left << " " << rcItem.bottom << " " << rcItem.Width() << " " << rcItem.Height() << " re f\n" << "Q\n";
- sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP(CPVT_Color(CT_GRAY, 1), true) << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), CPDF_Point(0.0f, fy), true, 0) << "ET\n";
+ sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP(CPVT_Color(CT_GRAY, 1), TRUE) << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), CPDF_Point(0.0f, fy), TRUE, 0) << "ET\n";
} else {
- sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, true) << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), CPDF_Point(0.0f, fy), true, 0) << "ET\n";
+ sBody << "BT\n" << CPVT_GenerateAP::GenerateColorAP(crText, TRUE) << CPVT_GenerateAP::GenerateEditAP(&map, vt.GetIterator(), CPDF_Point(0.0f, fy), TRUE, 0) << "ET\n";
}
fy -= fItemHeight;
}
@@ -598,7 +598,7 @@ static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, c
break;
}
if (pNormalStream) {
- pNormalStream->SetData((uint8_t*)sAppStream.GetBuffer(), sAppStream.GetSize(), false, false);
+ pNormalStream->SetData((uint8_t*)sAppStream.GetBuffer(), sAppStream.GetSize(), FALSE, FALSE);
pStreamDict = pNormalStream->GetDict();
if (pStreamDict) {
pStreamDict->SetAtMatrix("Matrix", matrix);
@@ -609,7 +609,7 @@ static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, c
if (!pStreamResFontList) {
pStreamResFontList = CPDF_Dictionary::Create();
if (pStreamResFontList == NULL) {
- return false;
+ return FALSE;
}
pStreamResList->SetAt("Font", pStreamResFontList);
}
@@ -622,21 +622,21 @@ static bool GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict, c
}
}
}
- return true;
+ return TRUE;
}
-bool CPVT_GenerateAP::GenerateTextFieldAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict)
+FX_BOOL CPVT_GenerateAP::GenerateTextFieldAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict)
{
return GenerateWidgetAP(pDoc, pAnnotDict, 0);
}
-bool CPVT_GenerateAP::GenerateComboBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict)
+FX_BOOL CPVT_GenerateAP::GenerateComboBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict)
{
return GenerateWidgetAP(pDoc, pAnnotDict, 1);
}
-bool CPVT_GenerateAP::GenerateListBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict)
+FX_BOOL CPVT_GenerateAP::GenerateListBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict)
{
return GenerateWidgetAP(pDoc, pAnnotDict, 2);
}
-CFX_ByteString CPVT_GenerateAP::GenerateEditAP(IPVT_FontMap * pFontMap, IPDF_VariableText_Iterator* pIterator, const CPDF_Point & ptOffset, bool bContinuous, FX_WORD SubWord, const CPVT_WordRange * pVisible)
+CFX_ByteString CPVT_GenerateAP::GenerateEditAP(IPVT_FontMap * pFontMap, IPDF_VariableText_Iterator* pIterator, const CPDF_Point & ptOffset, FX_BOOL bContinuous, FX_WORD SubWord, const CPVT_WordRange * pVisible)
{
CFX_ByteTextBuf sEditStream, sLineStream, sWords;
CPDF_Point ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f);
@@ -726,7 +726,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(const CPDF_Rect & rect, FX_FLOA
switch (nStyle) {
default:
case PBS_SOLID:
- sColor = GenerateColorAP(color, true);
+ sColor = GenerateColorAP(color, TRUE);
if (sColor.GetLength() > 0) {
sAppStream << sColor;
sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " << fTop - fBottom << " re\n";
@@ -736,7 +736,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(const CPDF_Rect & rect, FX_FLOA
}
break;
case PBS_DASH:
- sColor = GenerateColorAP(color, false);
+ sColor = GenerateColorAP(color, FALSE);
if (sColor.GetLength() > 0) {
sAppStream << sColor;
sAppStream << fWidth << " w" << " [" << dash.nDash << " " << dash.nGap << "] " << dash.nPhase << " d\n";
@@ -749,7 +749,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(const CPDF_Rect & rect, FX_FLOA
break;
case PBS_BEVELED:
case PBS_INSET:
- sColor = GenerateColorAP(crLeftTop, true);
+ sColor = GenerateColorAP(crLeftTop, TRUE);
if (sColor.GetLength() > 0) {
sAppStream << sColor;
sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " m\n";
@@ -759,7 +759,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(const CPDF_Rect & rect, FX_FLOA
sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 << " l\n";
sAppStream << fLeft + fHalfWidth * 2 << " " << fBottom + fHalfWidth * 2 << " l f\n";
}
- sColor = GenerateColorAP(crRightBottom, true);
+ sColor = GenerateColorAP(crRightBottom, TRUE);
if (sColor.GetLength() > 0) {
sAppStream << sColor;
sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth << " m\n";
@@ -769,7 +769,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(const CPDF_Rect & rect, FX_FLOA
sAppStream << fRight - fHalfWidth * 2 << " " << fBottom + fHalfWidth * 2 << " l\n";
sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 << " l f\n";
}
- sColor = GenerateColorAP(color, true);
+ sColor = GenerateColorAP(color, TRUE);
if (sColor.GetLength() > 0) {
sAppStream << sColor;
sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " << fTop - fBottom << " re\n";
@@ -778,7 +778,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(const CPDF_Rect & rect, FX_FLOA
}
break;
case PBS_UNDERLINED:
- sColor = GenerateColorAP(color, false);
+ sColor = GenerateColorAP(color, FALSE);
if (sColor.GetLength() > 0) {
sAppStream << sColor;
sAppStream << fWidth << " w\n";
@@ -790,7 +790,7 @@ CFX_ByteString CPVT_GenerateAP::GenerateBorderAP(const CPDF_Rect & rect, FX_FLOA
}
return sAppStream.GetByteString();
}
-CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color & color, const bool & bFillOrStroke)
+CFX_ByteString CPVT_GenerateAP::GenerateColorAP(const CPVT_Color & color, const FX_BOOL & bFillOrStroke)
{
CFX_ByteTextBuf sColorStream;
switch (color.nColorType) {