Commit 163420b4 authored by Oliver Sander's avatar Oliver Sander Committed by Albert Astals Cid
Browse files

Replace GBool, gTrue, and gFalse by bool, true, false, resp.

These are just non-standard names for bool, true, false, respectively.
Getting rid of these names saves on layer of mental redirection,
and enables proper syntax highlighting in editors.
parent 22dd47a6
......@@ -292,14 +292,14 @@ image page_renderer::render_page(const page *p,
bgColor[0] = d->paper_color & 0xff;
bgColor[1] = (d->paper_color >> 8) & 0xff;
bgColor[2] = (d->paper_color >> 16) & 0xff;
SplashOutputDev splashOutputDev(colorMode, 4, gFalse, bgColor, gTrue, lineMode);
splashOutputDev.setFontAntialias(d->hints & text_antialiasing ? gTrue : gFalse);
splashOutputDev.setVectorAntialias(d->hints & antialiasing ? gTrue : gFalse);
splashOutputDev.setFreeTypeHinting(d->hints & text_hinting ? gTrue : gFalse, gFalse);
SplashOutputDev splashOutputDev(colorMode, 4, false, bgColor, true, lineMode);
splashOutputDev.setFontAntialias(d->hints & text_antialiasing ? true : false);
splashOutputDev.setVectorAntialias(d->hints & antialiasing ? true : false);
splashOutputDev.setFreeTypeHinting(d->hints & text_hinting ? true : false, false);
splashOutputDev.startDoc(pdfdoc);
pdfdoc->displayPageSlice(&splashOutputDev, pp->index + 1,
xres, yres, int(rotate) * 90,
gFalse, gTrue, gFalse,
false, true, false,
x, y, w, h);
SplashBitmap *bitmap = splashOutputDev.getBitmap();
......
......@@ -206,7 +206,7 @@ bool page::search(const ustring &text, rectf &r, search_direction_enum direction
u[i] = text[i];
}
const GBool sCase = case_sensitivity == case_sensitive ? gTrue : gFalse;
const bool sCase = case_sensitivity == case_sensitive;
const int rotation_value = (int)rotation * 90;
bool found = false;
......@@ -215,24 +215,24 @@ bool page::search(const ustring &text, rectf &r, search_direction_enum direction
double rect_right = r.right();
double rect_bottom = r.bottom();
TextOutputDev td(nullptr, gTrue, 0, gFalse, gFalse);
TextOutputDev td(nullptr, true, 0, false, false);
d->doc->doc->displayPage(&td, d->index + 1, 72, 72, rotation_value, false, true, false);
TextPage *text_page = td.takeText();
switch (direction) {
case search_from_top:
found = text_page->findText(&u[0], len,
gTrue, gTrue, gFalse, gFalse, sCase, gFalse, gFalse,
true, true, false, false, sCase, false, false,
&rect_left, &rect_top, &rect_right, &rect_bottom);
break;
case search_next_result:
found = text_page->findText(&u[0], len,
gFalse, gTrue, gTrue, gFalse, sCase, gFalse, gFalse,
false, true, true, false, sCase, false, false,
&rect_left, &rect_top, &rect_right, &rect_bottom);
break;
case search_previous_result:
found = text_page->findText(&u[0], len,
gFalse, gTrue, gTrue, gFalse, sCase, gTrue, gFalse,
false, true, true, false, sCase, true, false,
&rect_left, &rect_top, &rect_right, &rect_bottom);
break;
}
......@@ -273,8 +273,8 @@ ustring page::text(const rectf &r) const
ustring page::text(const rectf &r, text_layout_enum layout_mode) const
{
std::unique_ptr<GooString> s;
const GBool use_raw_order = (layout_mode == raw_order_layout);
TextOutputDev td(nullptr, gFalse, 0, use_raw_order, gFalse);
const bool use_raw_order = (layout_mode == raw_order_layout);
TextOutputDev td(nullptr, false, 0, use_raw_order, false);
d->doc->doc->displayPage(&td, d->index + 1, 72, 72, 0, false, true, false);
if (r.is_empty()) {
PDFRectangle rect = *d->page->getCropBox();
......@@ -338,10 +338,10 @@ std::vector<text_box> page::text_list() const
/* config values are same with Qt5 Page::TextList() */
auto output_dev = std::make_unique<TextOutputDev>(
nullptr, /* char* fileName */
gFalse, /* GBool physLayoutA */
false, /* bool physLayoutA */
0, /* double fixedPitchA */
gFalse, /* GBool rawOrderA */
gFalse /* GBool append */
false, /* bool rawOrderA */
false /* bool append */
);
/*
......@@ -352,11 +352,11 @@ std::vector<text_box> page::text_list() const
d->doc->doc->displayPageSlice(output_dev.get(),
d->index + 1, /* page */
72, 72, 0, /* hDPI, vDPI, rot */
gFalse, gFalse, gFalse, /* useMediaBox, crop, printing */
false, false, false, /* useMediaBox, crop, printing */
-1, -1, -1, -1, /* sliceX, sliceY, sliceW, sliceH */
nullptr, nullptr, /* abortCheckCbk(), abortCheckCbkData */
nullptr, nullptr, /* annotDisplayDecideCbk(), annotDisplayDecideCbkData */
gTrue); /* copyXRef */
true); /* copyXRef */
if (std::unique_ptr< TextWordList > word_list{output_dev->makeWordList()}) {
......@@ -375,7 +375,7 @@ std::vector<text_box> page::text_list() const
{xMin, yMin, xMax-xMin, yMax-yMin},
word->getRotation(),
{},
word->hasSpaceAfter() == gTrue
word->hasSpaceAfter() == true
}};
tb.m_data->char_bboxes.reserve(word->getLength());
......
......@@ -34,7 +34,7 @@
// FoFiBase
//------------------------------------------------------------------------
FoFiBase::FoFiBase(const char *fileA, int lenA, GBool freeFileDataA) {
FoFiBase::FoFiBase(const char *fileA, int lenA, bool freeFileDataA) {
file = (const Guchar *)fileA;
len = lenA;
freeFileData = freeFileDataA;
......@@ -82,11 +82,11 @@ char *FoFiBase::readFile(const char *fileName, int *fileLen) {
return buf;
}
int FoFiBase::getS8(int pos, GBool *ok) const {
int FoFiBase::getS8(int pos, bool *ok) const {
int x;
if (pos < 0 || pos >= len) {
*ok = gFalse;
*ok = false;
return 0;
}
x = file[pos];
......@@ -96,19 +96,19 @@ int FoFiBase::getS8(int pos, GBool *ok) const {
return x;
}
int FoFiBase::getU8(int pos, GBool *ok) const {
int FoFiBase::getU8(int pos, bool *ok) const {
if (pos < 0 || pos >= len) {
*ok = gFalse;
*ok = false;
return 0;
}
return file[pos];
}
int FoFiBase::getS16BE(int pos, GBool *ok) const {
int FoFiBase::getS16BE(int pos, bool *ok) const {
int x;
if (pos < 0 || pos+1 >= len || pos > INT_MAX - 1) {
*ok = gFalse;
*ok = false;
return 0;
}
x = file[pos];
......@@ -119,11 +119,11 @@ int FoFiBase::getS16BE(int pos, GBool *ok) const {
return x;
}
int FoFiBase::getU16BE(int pos, GBool *ok) const {
int FoFiBase::getU16BE(int pos, bool *ok) const {
int x;
if (pos < 0 || pos+1 >= len || pos > INT_MAX - 1) {
*ok = gFalse;
*ok = false;
return 0;
}
x = file[pos];
......@@ -131,11 +131,11 @@ int FoFiBase::getU16BE(int pos, GBool *ok) const {
return x;
}
int FoFiBase::getS32BE(int pos, GBool *ok) const {
int FoFiBase::getS32BE(int pos, bool *ok) const {
int x;
if (pos < 0 || pos+3 >= len || pos > INT_MAX - 3) {
*ok = gFalse;
*ok = false;
return 0;
}
x = file[pos];
......@@ -148,11 +148,11 @@ int FoFiBase::getS32BE(int pos, GBool *ok) const {
return x;
}
Guint FoFiBase::getU32BE(int pos, GBool *ok) const {
Guint FoFiBase::getU32BE(int pos, bool *ok) const {
Guint x;
if (pos < 0 || pos+3 >= len || pos > INT_MAX - 3) {
*ok = gFalse;
*ok = false;
return 0;
}
x = file[pos];
......@@ -162,11 +162,11 @@ Guint FoFiBase::getU32BE(int pos, GBool *ok) const {
return x;
}
Guint FoFiBase::getU32LE(int pos, GBool *ok) const {
Guint FoFiBase::getU32LE(int pos, bool *ok) const {
Guint x;
if (pos < 0 || pos+3 >= len || pos > INT_MAX - 3) {
*ok = gFalse;
*ok = false;
return 0;
}
x = file[pos+3];
......@@ -176,12 +176,12 @@ Guint FoFiBase::getU32LE(int pos, GBool *ok) const {
return x;
}
Guint FoFiBase::getUVarBE(int pos, int size, GBool *ok) const {
Guint FoFiBase::getUVarBE(int pos, int size, bool *ok) const {
Guint x;
int i;
if (pos < 0 || pos + size > len || pos > INT_MAX - size) {
*ok = gFalse;
*ok = false;
return 0;
}
x = 0;
......@@ -191,7 +191,7 @@ Guint FoFiBase::getUVarBE(int pos, int size, GBool *ok) const {
return x;
}
GBool FoFiBase::checkRegion(int pos, int size) const {
bool FoFiBase::checkRegion(int pos, int size) const {
return pos >= 0 &&
pos < INT_MAX - size &&
size < INT_MAX - pos &&
......
......@@ -42,26 +42,26 @@ public:
protected:
FoFiBase(const char *fileA, int lenA, GBool freeFileDataA);
FoFiBase(const char *fileA, int lenA, bool freeFileDataA);
static char *readFile(const char *fileName, int *fileLen);
// S = signed / U = unsigned
// 8/16/32/Var = word length, in bytes
// BE = big endian
int getS8(int pos, GBool *ok) const;
int getU8(int pos, GBool *ok) const;
int getS16BE(int pos, GBool *ok) const;
int getU16BE(int pos, GBool *ok) const;
int getS32BE(int pos, GBool *ok) const;
Guint getU32BE(int pos, GBool *ok) const;
Guint getU32LE(int pos, GBool *ok) const;
Guint getUVarBE(int pos, int size, GBool *ok) const;
int getS8(int pos, bool *ok) const;
int getU8(int pos, bool *ok) const;
int getS16BE(int pos, bool *ok) const;
int getU16BE(int pos, bool *ok) const;
int getS32BE(int pos, bool *ok) const;
Guint getU32BE(int pos, bool *ok) const;
Guint getU32LE(int pos, bool *ok) const;
Guint getUVarBE(int pos, int size, bool *ok) const;
GBool checkRegion(int pos, int size) const;
bool checkRegion(int pos, int size) const;
const Guchar *file;
int len;
GBool freeFileData;
bool freeFileData;
};
#endif
......@@ -44,22 +44,22 @@ public:
// Read a big-endian unsigned 16-bit integer. Fills in *val and
// returns true if successful.
virtual GBool getU16BE(int pos, int *val) = 0;
virtual bool getU16BE(int pos, int *val) = 0;
// Read a big-endian unsigned 32-bit integer. Fills in *val and
// returns true if successful.
virtual GBool getU32BE(int pos, Guint *val) = 0;
virtual bool getU32BE(int pos, Guint *val) = 0;
// Read a little-endian unsigned 32-bit integer. Fills in *val and
// returns true if successful.
virtual GBool getU32LE(int pos, Guint *val) = 0;
virtual bool getU32LE(int pos, Guint *val) = 0;
// Read a big-endian unsigned <size>-byte integer, where 1 <= size
// <= 4. Fills in *val and returns true if successful.
virtual GBool getUVarBE(int pos, int size, Guint *val) = 0;
virtual bool getUVarBE(int pos, int size, Guint *val) = 0;
// Compare against a string. Returns true if equal.
virtual GBool cmp(int pos, const char *s) = 0;
virtual bool cmp(int pos, const char *s) = 0;
};
......@@ -71,11 +71,11 @@ public:
static MemReader *make(const char *bufA, int lenA);
~MemReader();
int getByte(int pos) override;
GBool getU16BE(int pos, int *val) override;
GBool getU32BE(int pos, Guint *val) override;
GBool getU32LE(int pos, Guint *val) override;
GBool getUVarBE(int pos, int size, Guint *val) override;
GBool cmp(int pos, const char *s) override;
bool getU16BE(int pos, int *val) override;
bool getU32BE(int pos, Guint *val) override;
bool getU32LE(int pos, Guint *val) override;
bool getUVarBE(int pos, int size, Guint *val) override;
bool cmp(int pos, const char *s) override;
private:
......@@ -104,56 +104,56 @@ int MemReader::getByte(int pos) {
return buf[pos] & 0xff;
}
GBool MemReader::getU16BE(int pos, int *val) {
bool MemReader::getU16BE(int pos, int *val) {
if (pos < 0 || pos > len - 2) {
return gFalse;
return false;
}
*val = ((buf[pos] & 0xff) << 8) +
(buf[pos+1] & 0xff);
return gTrue;
return true;
}
GBool MemReader::getU32BE(int pos, Guint *val) {
bool MemReader::getU32BE(int pos, Guint *val) {
if (pos < 0 || pos > len - 4) {
return gFalse;
return false;
}
*val = ((buf[pos] & 0xff) << 24) +
((buf[pos+1] & 0xff) << 16) +
((buf[pos+2] & 0xff) << 8) +
(buf[pos+3] & 0xff);
return gTrue;
return true;
}
GBool MemReader::getU32LE(int pos, Guint *val) {
bool MemReader::getU32LE(int pos, Guint *val) {
if (pos < 0 || pos > len - 4) {
return gFalse;
return false;
}
*val = (buf[pos] & 0xff) +
((buf[pos+1] & 0xff) << 8) +
((buf[pos+2] & 0xff) << 16) +
((buf[pos+3] & 0xff) << 24);
return gTrue;
return true;
}
GBool MemReader::getUVarBE(int pos, int size, Guint *val) {
bool MemReader::getUVarBE(int pos, int size, Guint *val) {
int i;
if (size < 1 || size > 4 || pos < 0 || pos > len - size) {
return gFalse;
return false;
}
*val = 0;
for (i = 0; i < size; ++i) {
*val = (*val << 8) + (buf[pos + i] & 0xff);
}
return gTrue;
return true;
}
GBool MemReader::cmp(int pos, const char *s) {
bool MemReader::cmp(int pos, const char *s) {
int n;
n = (int)strlen(s);
if (pos < 0 || len < n || pos > len - n) {
return gFalse;
return false;
}
return !memcmp(buf + pos, s, n);
}
......@@ -166,16 +166,16 @@ public:
static FileReader *make(const char *fileName);
~FileReader();
int getByte(int pos) override;
GBool getU16BE(int pos, int *val) override;
GBool getU32BE(int pos, Guint *val) override;
GBool getU32LE(int pos, Guint *val) override;
GBool getUVarBE(int pos, int size, Guint *val) override;
GBool cmp(int pos, const char *s) override;
bool getU16BE(int pos, int *val) override;
bool getU32BE(int pos, Guint *val) override;
bool getU32LE(int pos, Guint *val) override;
bool getUVarBE(int pos, int size, Guint *val) override;
bool cmp(int pos, const char *s) override;
private:
FileReader(FILE *fA);
GBool fillBuf(int pos, int len);
bool fillBuf(int pos, int len);
FILE *f;
char buf[1024];
......@@ -208,77 +208,77 @@ int FileReader::getByte(int pos) {
return buf[pos - bufPos] & 0xff;
}
GBool FileReader::getU16BE(int pos, int *val) {
bool FileReader::getU16BE(int pos, int *val) {
if (!fillBuf(pos, 2)) {
return gFalse;
return false;
}
*val = ((buf[pos - bufPos] & 0xff) << 8) +
(buf[pos - bufPos + 1] & 0xff);
return gTrue;
return true;
}
GBool FileReader::getU32BE(int pos, Guint *val) {
bool FileReader::getU32BE(int pos, Guint *val) {
if (!fillBuf(pos, 4)) {
return gFalse;
return false;
}
*val = ((buf[pos - bufPos] & 0xff) << 24) +
((buf[pos - bufPos + 1] & 0xff) << 16) +
((buf[pos - bufPos + 2] & 0xff) << 8) +
(buf[pos - bufPos + 3] & 0xff);
return gTrue;
return true;
}
GBool FileReader::getU32LE(int pos, Guint *val) {
bool FileReader::getU32LE(int pos, Guint *val) {
if (!fillBuf(pos, 4)) {
return gFalse;
return false;
}
*val = (buf[pos - bufPos] & 0xff) +
((buf[pos - bufPos + 1] & 0xff) << 8) +
((buf[pos - bufPos + 2] & 0xff) << 16) +
((buf[pos - bufPos + 3] & 0xff) << 24);
return gTrue;
return true;
}
GBool FileReader::getUVarBE(int pos, int size, Guint *val) {
bool FileReader::getUVarBE(int pos, int size, Guint *val) {
int i;
if (size < 1 || size > 4 || !fillBuf(pos, size)) {
return gFalse;
return false;
}
*val = 0;
for (i = 0; i < size; ++i) {
*val = (*val << 8) + (buf[pos - bufPos + i] & 0xff);
}
return gTrue;
return true;
}
GBool FileReader::cmp(int pos, const char *s) {
bool FileReader::cmp(int pos, const char *s) {
int n;
n = (int)strlen(s);
if (!fillBuf(pos, n)) {
return gFalse;
return false;
}
return !memcmp(buf - bufPos + pos, s, n);
}
GBool FileReader::fillBuf(int pos, int len) {
bool FileReader::fillBuf(int pos, int len) {
if (pos < 0 || len < 0 || len > (int)sizeof(buf) ||
pos > INT_MAX - (int)sizeof(buf)) {
return gFalse;
return false;
}
if (pos >= bufPos && pos + len <= bufPos + bufLen) {
return gTrue;
return true;
}
if (fseek(f, pos, SEEK_SET)) {
return gFalse;
return false;
}
bufPos = pos;
bufLen = (int)fread(buf, 1, sizeof(buf), f);
if (bufLen < len) {
return gFalse;
return false;
}
return gTrue;
return true;
}
//------------------------------------------------------------------------
......@@ -289,16 +289,16 @@ public:
static StreamReader *make(int (*getCharA)(void *data), void *dataA);
~StreamReader();
int getByte(int pos) override;
GBool getU16BE(int pos, int *val) override;
GBool getU32BE(int pos, Guint *val) override;
GBool getU32LE(int pos, Guint *val) override;
GBool getUVarBE(int pos, int size, Guint *val) override;
GBool cmp(int pos, const char *s) override;
bool getU16BE(int pos, int *val) override;
bool getU32BE(int pos, Guint *val) override;
bool getU32LE(int pos, Guint *val) override;
bool getUVarBE(int pos, int size, Guint *val) override;
bool cmp(int pos, const char *s) override;
private:
StreamReader(int (*getCharA)(void *data), void *dataA);
GBool fillBuf(int pos, int len);
bool fillBuf(int pos, int len);
int (*getChar)(void *data);
void *data;
......@@ -329,68 +329,68 @@ int StreamReader::getByte(int pos) {
return buf[pos - bufPos] & 0xff;
}
GBool StreamReader::getU16BE(int pos, int *val) {
bool StreamReader::getU16BE(int pos, int *val) {
if (!fillBuf(pos, 2)) {
return gFalse;
return false;
}
*val = ((buf[pos - bufPos] & 0xff) << 8) +
(buf[pos - bufPos + 1] & 0xff);
return gTrue;
return true;
}
GBool StreamReader::getU32BE(int pos, Guint *val) {
bool StreamReader::getU32BE(int pos, Guint *val) {
if (!fillBuf(pos, 4)) {
return gFalse;
return false;
}
*val = ((buf[pos - bufPos] & 0xff) << 24) +
((buf[pos - bufPos + 1] & 0xff) << 16) +
((buf[pos - bufPos + 2] & 0xff) << 8) +
(buf[pos - bufPos + 3] & 0xff);
return gTrue;
return true;
}
GBool StreamReader::getU32LE(int pos, Guint *val) {
bool StreamReader::getU32LE(int pos, Guint *val) {
if (!fillBuf(pos, 4)) {
return gFalse;
return false;
}
*val = (buf[pos - bufPos] & 0xff) +
((buf[pos - bufPos + 1] & 0xff) << 8) +
((buf[pos - bufPos + 2] & 0xff) << 16) +
((buf[pos - bufPos + 3] & 0xff) << 24);
return gTrue;
return true;
}
GBool StreamReader::getUVarBE(int pos, int size, Guint *val) {
bool StreamReader::getUVarBE(int pos, int size, Guint *val) {
int i;
if (size < 1 || size > 4 || !fillBuf(pos, size)) {
return gFalse;
return false;
}
*val = 0;
for (i = 0; i < size; ++i) {
*val = (*val << 8) + (buf[pos - bufPos + i] & 0xff);
}
return gTrue;
return true;
}
GBool StreamReader::cmp(int pos, const char *s) {
bool StreamReader::cmp(int pos, const char *s) {
const int n = (int)strlen(s);
if (!fillBuf(pos, n)) {
return gFalse;
return false;
}
const int posDiff = pos - bufPos;
return !memcmp(buf + posDiff, s, n);