diff --git a/src/BackgroundRenderer/CairoBackgroundRenderer.cc b/src/BackgroundRenderer/CairoBackgroundRenderer.cc index fac4904..a7eaed8 100644 --- a/src/BackgroundRenderer/CairoBackgroundRenderer.cc +++ b/src/BackgroundRenderer/CairoBackgroundRenderer.cc @@ -107,8 +107,8 @@ void CairoBackgroundRenderer::init(PDFDoc * doc) startDoc(doc); } -static GBool annot_cb(Annot *, void * pflag) { - return (*((bool*)pflag)) ? gTrue : gFalse; +static bool annot_cb(Annot *, void * pflag) { + return (*((bool*)pflag)) ? true : false; }; bool CairoBackgroundRenderer::render_page(PDFDoc * doc, int pageno) diff --git a/src/BackgroundRenderer/CairoBackgroundRenderer.h b/src/BackgroundRenderer/CairoBackgroundRenderer.h index b354cdc..d5c8637 100644 --- a/src/BackgroundRenderer/CairoBackgroundRenderer.h +++ b/src/BackgroundRenderer/CairoBackgroundRenderer.h @@ -37,7 +37,7 @@ public: // Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. - virtual GBool interpretType3Chars() { return !param.process_type3; } + virtual bool interpretType3Chars() { return !param.process_type3; } virtual void drawChar(GfxState *state, double x, double y, double dx, double dy, diff --git a/src/BackgroundRenderer/SplashBackgroundRenderer.cc b/src/BackgroundRenderer/SplashBackgroundRenderer.cc index a7a23d8..be14222 100644 --- a/src/BackgroundRenderer/SplashBackgroundRenderer.cc +++ b/src/BackgroundRenderer/SplashBackgroundRenderer.cc @@ -29,7 +29,7 @@ using std::unique_ptr; const SplashColor SplashBackgroundRenderer::white = {255,255,255}; SplashBackgroundRenderer::SplashBackgroundRenderer(const string & imgFormat, HTMLRenderer * html_renderer, const Param & param) - : SplashOutputDev(splashModeRGB8, 4, gFalse, (SplashColorPtr)(&white), gTrue, splashThinLineSolid) // DCRH: Make thin line mode = solid + : SplashOutputDev(splashModeRGB8, 4, false, (SplashColorPtr)(&white), true, splashThinLineSolid) // DCRH: Make thin line mode = solid , html_renderer(html_renderer) , param(param) , format(imgFormat) @@ -106,8 +106,8 @@ void SplashBackgroundRenderer::init(PDFDoc * doc) startDoc(doc); } -static GBool annot_cb(Annot *, void * pflag) { - return (*((bool*)pflag)) ? gTrue : gFalse; +static bool annot_cb(Annot *, void * pflag) { + return (*((bool*)pflag)) ? true : false; }; bool SplashBackgroundRenderer::render_page(PDFDoc * doc, int pageno) diff --git a/src/BackgroundRenderer/SplashBackgroundRenderer.h b/src/BackgroundRenderer/SplashBackgroundRenderer.h index 8b11da6..55baeb3 100644 --- a/src/BackgroundRenderer/SplashBackgroundRenderer.h +++ b/src/BackgroundRenderer/SplashBackgroundRenderer.h @@ -37,7 +37,7 @@ public: // Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. - virtual GBool interpretType3Chars() { return !param.process_type3; } + virtual bool interpretType3Chars() { return !param.process_type3; } virtual void startPage(int pageNum, GfxState *state, XRef *xrefA); diff --git a/src/HTMLRenderer/HTMLRenderer.h b/src/HTMLRenderer/HTMLRenderer.h index 7ec04bf..329f868 100644 --- a/src/HTMLRenderer/HTMLRenderer.h +++ b/src/HTMLRenderer/HTMLRenderer.h @@ -16,7 +16,34 @@ #include #include #include -#include + +/************ from goo/gtypes.h ***************/ +// #include + +/* + * These have stupid names to avoid conflicts with some (but not all) + * C++ compilers which define them. + */ +//typedef bool GBool; +//#define gTrue true +//#define gFalse false + +//#ifdef _MSC_VER +//#pragma warning(disable: 4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */ +//#endif + +/* + * These have stupid names to avoid conflicts with , + * which on various systems defines some random subset of these. + */ +//typedef unsigned char Guchar; +//typedef unsigned short Gushort; +//typedef unsigned int Guint; +//typedef unsigned long Gulong; +//typedef long long Goffset; + +/**********************************************/ + #include #include #include @@ -58,28 +85,28 @@ struct HTMLRenderer : OutputDev // Does this device use upside-down coordinates? // (Upside-down means (0,0) is the top left corner of the page.) - virtual GBool upsideDown() { return gFalse; } + virtual bool upsideDown() { return false; } // Does this device use drawChar() or drawString()? - virtual GBool useDrawChar() { return gFalse; } + virtual bool useDrawChar() { return false; } // Does this device use functionShadedFill(), axialShadedFill(), and // radialShadedFill()? If this returns false, these shaded fills // will be reduced to a series of other drawing operations. - virtual GBool useShadedFills(int type) { return (type == 2) ? gTrue: gFalse; } + virtual bool useShadedFills(int type) { return (type == 2) ? true: false; } // Does this device use beginType3Char/endType3Char? Otherwise, // text in Type 3 fonts will be drawn with drawChar/drawString. - virtual GBool interpretType3Chars() { return gFalse; } + virtual bool interpretType3Chars() { return false; } // Does this device need non-text content? - virtual GBool needNonText() { return (param.process_nontext) ? gTrue: gFalse; } + virtual bool needNonText() { return (param.process_nontext) ? true: false; } // Does this device need to clip pages to the crop box even when the // box is the crop box? - virtual GBool needClipToCropBox() { return gTrue; } + virtual bool needClipToCropBox() { return true; } - virtual void setDefaultCTM(double *ctm); + virtual void setDefaultCTM(const double *ctm); // Start a page. virtual void startPage(int pageNum, GfxState *state, XRef * xref); @@ -128,26 +155,26 @@ struct HTMLRenderer : OutputDev virtual void drawString(GfxState * state, const GooString * s); - virtual void drawImage(GfxState * state, Object * ref, Stream * str, int width, int height, GfxImageColorMap * colorMap, GBool interpolate, int *maskColors, GBool inlineImg); + virtual void drawImage(GfxState * state, Object * ref, Stream * str, int width, int height, GfxImageColorMap * colorMap, bool interpolate, int *maskColors, bool inlineImg); virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, - GBool interpolate, + bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap, - GBool maskInterpolate); + bool maskInterpolate); virtual void stroke(GfxState *state); virtual void fill(GfxState *state); virtual void eoFill(GfxState *state); - virtual GBool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax); + virtual bool axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax); - virtual void beginTransparencyGroup(GfxState * /*state*/, double * /*bbox*/, + virtual void beginTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/, GfxColorSpace * /*blendingColorSpace*/, - GBool /*isolated*/, GBool /*knockout*/, - GBool /*forSoftMask*/); + bool /*isolated*/, bool /*knockout*/, + bool /*forSoftMask*/); virtual void endTransparencyGroup(GfxState * /*state*/); @@ -319,7 +346,7 @@ protected: // for font reencoding std::vector cur_mapping; - std::vector cur_mapping2; + std::vector cur_mapping2; std::vector width_list; // width of each char Preprocessor preprocessor; diff --git a/src/HTMLRenderer/draw.cc b/src/HTMLRenderer/draw.cc index 61460df..39cfa9c 100644 --- a/src/HTMLRenderer/draw.cc +++ b/src/HTMLRenderer/draw.cc @@ -56,16 +56,16 @@ void HTMLRenderer::eoFill(GfxState * state) tracer.fill(state, true); } -GBool HTMLRenderer::axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) +bool HTMLRenderer::axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) { tracer.fill(state); //TODO correct? return true; } -void HTMLRenderer::beginTransparencyGroup(GfxState *state, double *bbox, +void HTMLRenderer::beginTransparencyGroup(GfxState *state, const double *bbox, GfxColorSpace *blendingColorSpace, - GBool isolated, GBool knockout, - GBool forSoftMask) { + bool isolated, bool knockout, + bool forSoftMask) { inTransparencyGroup++; } void HTMLRenderer::endTransparencyGroup(GfxState *state) { diff --git a/src/HTMLRenderer/font.cc b/src/HTMLRenderer/font.cc index 301bf30..56ad2f5 100644 --- a/src/HTMLRenderer/font.cc +++ b/src/HTMLRenderer/font.cc @@ -169,7 +169,7 @@ string HTMLRenderer::dump_embedded_font (GfxFont * font, FontInfo & info) char buf[1024]; int len; - while((len = obj.streamGetChars(1024, (Guchar*)buf)) > 0) + while((len = obj.streamGetChars(1024, (unsigned char*)buf)) > 0) { outf.write(buf, len); } @@ -205,8 +205,8 @@ string HTMLRenderer::dump_type3_font (GfxFont * font, FontInfo & info) auto used_map = preprocessor.get_code_map(hash_ref(font->getID())); //calculate transformed metrics - double * font_bbox = font->getFontBBox(); - double * font_matrix = font->getFontMatrix(); + const double * font_bbox = font->getFontBBox(); + const double * font_matrix = font->getFontMatrix(); double transformed_bbox[4]; memcpy(transformed_bbox, font_bbox, 4 * sizeof(double)); /* @@ -337,7 +337,7 @@ string HTMLRenderer::dump_type3_font (GfxFont * font, FontInfo & info) &box, nullptr); output_dev->startDoc(cur_doc, &font_engine); output_dev->startPage(1, gfx->getState(), gfx->getXRef()); - output_dev->setInType3Char(gTrue); + output_dev->setInType3Char(true); auto char_procs = ((Gfx8BitFont*)font)->getCharProcs(); Object char_proc_obj; auto glyph_index = cur_font->getGlyph(code, nullptr, 0); @@ -640,8 +640,8 @@ void HTMLRenderer::embed_font(const string & filepath, GfxFont * font, FontInfo if(info.use_tounicode) { int n = ctu ? - (((CharCodeToUnicode *)ctu)->mapToUnicode(cur_code, &pu)) : - 0; + (((CharCodeToUnicode *)ctu)->mapToUnicode(cur_code, &pu)) : + 0; u = check_unicode(pu, n, cur_code, font); } else @@ -877,7 +877,7 @@ const FontInfo * HTMLRenderer::install_font(GfxFont * font) { cerr << "Install font " << hex << new_fn_id << dec << ": (" << (font->getID()->num) << ' ' << (font->getID()->gen) << ") " - << (font->getName() ? font->getName()->getCString() : "") + << (font->getName() ? font->getName()->toStr() : "") << endl; } @@ -907,7 +907,7 @@ const FontInfo * HTMLRenderer::install_font(GfxFont * font) /* * The 2nd parameter of locateFont should be true only for PS * which does not make much sense in our case - * If we specify gFalse here, font_loc->locType cannot be gfxFontLocResident + * If we specify false here, font_loc->locType cannot be gfxFontLocResident */ if(auto * font_loc = font->locateFont(xref, nullptr)) { @@ -954,7 +954,7 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, FontInfo & info) void HTMLRenderer::install_external_font(GfxFont * font, FontInfo & info) { - string fontname(font->getName()->getCString()); + string fontname(font->getName()->toStr()); // resolve bad encodings in GB auto iter = GB_ENCODED_FONT_NAME_MAP.find(fontname); @@ -970,7 +970,7 @@ void HTMLRenderer::install_external_font(GfxFont * font, FontInfo & info) { if(localfontloc != nullptr) { - embed_font(string(localfontloc->path->getCString()), font, info); + embed_font(string(localfontloc->path->toStr()), font, info); export_remote_font(info, param.font_format, font); delete localfontloc; return; @@ -986,7 +986,7 @@ void HTMLRenderer::install_external_font(GfxFont * font, FontInfo & info) if(localfontloc != nullptr) { // fill in ascent/descent only, do not embed - embed_font(string(localfontloc->path->getCString()), font, info, true); + embed_font(string(localfontloc->path->toStr()), font, info, true); delete localfontloc; } else diff --git a/src/HTMLRenderer/general.cc b/src/HTMLRenderer/general.cc index c1e8825..459e091 100644 --- a/src/HTMLRenderer/general.cc +++ b/src/HTMLRenderer/general.cc @@ -53,7 +53,7 @@ HTMLRenderer::HTMLRenderer(Param & param) if(!(param.debug)) { //disable error messages of poppler - globalParams->setErrQuiet(gTrue); + globalParams->setErrQuiet(true); } ffw_init(param.debug); @@ -190,7 +190,7 @@ void HTMLRenderer::process(PDFDoc *doc) cerr << endl; } -void HTMLRenderer::setDefaultCTM(double *ctm) +void HTMLRenderer::setDefaultCTM(const double *ctm) { memcpy(default_ctm, ctm, sizeof(default_ctm)); } diff --git a/src/HTMLRenderer/image.cc b/src/HTMLRenderer/image.cc index 91ca767..ef51ffc 100644 --- a/src/HTMLRenderer/image.cc +++ b/src/HTMLRenderer/image.cc @@ -12,7 +12,7 @@ namespace pdf2htmlEX { -void HTMLRenderer::drawImage(GfxState * state, Object * ref, Stream * str, int width, int height, GfxImageColorMap * colorMap, GBool interpolate, int *maskColors, GBool inlineImg) +void HTMLRenderer::drawImage(GfxState * state, Object * ref, Stream * str, int width, int height, GfxImageColorMap * colorMap, bool interpolate, int *maskColors, bool inlineImg) { tracer.draw_image(state); @@ -67,11 +67,11 @@ void HTMLRenderer::drawImage(GfxState * state, Object * ref, Stream * str, int w void HTMLRenderer::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, - GBool interpolate, + bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap, - GBool maskInterpolate) + bool maskInterpolate) { tracer.draw_image(state); diff --git a/src/HTMLRenderer/link.cc b/src/HTMLRenderer/link.cc index bf61e4a..9f3a62d 100644 --- a/src/HTMLRenderer/link.cc +++ b/src/HTMLRenderer/link.cc @@ -164,7 +164,7 @@ string HTMLRenderer::get_linkaction_str(const LinkAction * action, string & deta { auto * real_action = dynamic_cast(action); assert(real_action != nullptr); - dest_str = real_action->getURI()->getCString(); + dest_str = real_action->getURI()->toStr(); } break; case actionLaunch: diff --git a/src/HTMLRenderer/text.cc b/src/HTMLRenderer/text.cc index 16bb478..06df7aa 100644 --- a/src/HTMLRenderer/text.cc +++ b/src/HTMLRenderer/text.cc @@ -58,7 +58,7 @@ void HTMLRenderer::drawString(GfxState * state, const GooString * s) // Now ready to output // get the unicodes - const char *p = s->getCString(); + const char *p = (s->toStr()).c_str(); int len = s->getLength(); //accumulated displacement of chars in this string, in text object space diff --git a/src/Preprocessor.h b/src/Preprocessor.h index 5b48e4f..d121b59 100644 --- a/src/Preprocessor.h +++ b/src/Preprocessor.h @@ -30,11 +30,11 @@ public: void process(PDFDoc * doc); - virtual GBool upsideDown() { return gFalse; } - virtual GBool useDrawChar() { return gTrue; } - virtual GBool interpretType3Chars() { return gFalse; } - virtual GBool needNonText() { return gFalse; } - virtual GBool needClipToCropBox() { return gTrue; } + virtual bool upsideDown() { return false; } + virtual bool useDrawChar() { return true; } + virtual bool interpretType3Chars() { return false; } + virtual bool needNonText() { return false; } + virtual bool needClipToCropBox() { return true; } virtual void drawChar(GfxState *state, double x, double y, double dx, double dy, diff --git a/src/pdf2htmlEX.cc b/src/pdf2htmlEX.cc index 3bd35e6..bdc56aa 100644 --- a/src/pdf2htmlEX.cc +++ b/src/pdf2htmlEX.cc @@ -438,8 +438,9 @@ int main(int argc, char **argv) delete globalParams; // check for memory leaks - Object::memCheck(stderr); - gMemReport(stderr); + // Poppler Object class (Object.h) no longer has memCheck + //Object::memCheck(stderr); + //gMemReport(stderr); exit(finished ? (EXIT_SUCCESS) : (EXIT_FAILURE)); diff --git a/src/util/ffw.c b/src/util/ffw.c index ccd2643..c296f38 100644 --- a/src/util/ffw.c +++ b/src/util/ffw.c @@ -275,7 +275,7 @@ void ffw_reencode_raw(int32 * mapping, int mapping_len, int force) ffw_do_reencode(enc, force); } -void ffw_reencode_raw2(char ** mapping, int mapping_len, int force) +void ffw_reencode_raw2(const char ** mapping, int mapping_len, int force) { Encoding * enc = calloc(1, sizeof(Encoding)); enc->enc_name = strcopy(""); diff --git a/src/util/ffw.h b/src/util/ffw.h index a01ed79..106310a 100644 --- a/src/util/ffw.h +++ b/src/util/ffw.h @@ -39,7 +39,7 @@ void ffw_close(void); void ffw_reencode_glyph_order(void); void ffw_reencode_unicode_full(void); void ffw_reencode_raw(int32_t * mapping, int mapping_len, int force); -void ffw_reencode_raw2(char ** mapping, int mapping_len, int force); +void ffw_reencode_raw2(const char ** mapping, int mapping_len, int force); void ffw_cidflatten(void); // add a new empty char into the font diff --git a/src/util/unicode.cc b/src/util/unicode.cc index 1052ced..31ec4f8 100644 --- a/src/util/unicode.cc +++ b/src/util/unicode.cc @@ -42,7 +42,7 @@ Unicode unicode_from_font (CharCode code, GfxFont * font) { auto * font2 = dynamic_cast(font); assert(font2 != nullptr); - char * cname = font2->getCharName(code); + const char * cname = font2->getCharName(code); // may be untranslated ligature if(cname) {