1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 04:50:09 +00:00

rebased by hand update2poppler0_74_0ubuntu19_04 onto current master

This commit is contained in:
Stephen Gaito 2019-09-23 11:19:20 +01:00
parent 67aa27232c
commit fd34e6e671
16 changed files with 83 additions and 55 deletions

View File

@ -107,8 +107,8 @@ void CairoBackgroundRenderer::init(PDFDoc * doc)
startDoc(doc); startDoc(doc);
} }
static GBool annot_cb(Annot *, void * pflag) { static bool annot_cb(Annot *, void * pflag) {
return (*((bool*)pflag)) ? gTrue : gFalse; return (*((bool*)pflag)) ? true : false;
}; };
bool CairoBackgroundRenderer::render_page(PDFDoc * doc, int pageno) bool CairoBackgroundRenderer::render_page(PDFDoc * doc, int pageno)

View File

@ -37,7 +37,7 @@ public:
// Does this device use beginType3Char/endType3Char? Otherwise, // Does this device use beginType3Char/endType3Char? Otherwise,
// text in Type 3 fonts will be drawn with drawChar/drawString. // 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, virtual void drawChar(GfxState *state, double x, double y,
double dx, double dy, double dx, double dy,

View File

@ -29,7 +29,7 @@ using std::unique_ptr;
const SplashColor SplashBackgroundRenderer::white = {255,255,255}; const SplashColor SplashBackgroundRenderer::white = {255,255,255};
SplashBackgroundRenderer::SplashBackgroundRenderer(const string & imgFormat, HTMLRenderer * html_renderer, const Param & param) 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) , html_renderer(html_renderer)
, param(param) , param(param)
, format(imgFormat) , format(imgFormat)
@ -106,8 +106,8 @@ void SplashBackgroundRenderer::init(PDFDoc * doc)
startDoc(doc); startDoc(doc);
} }
static GBool annot_cb(Annot *, void * pflag) { static bool annot_cb(Annot *, void * pflag) {
return (*((bool*)pflag)) ? gTrue : gFalse; return (*((bool*)pflag)) ? true : false;
}; };
bool SplashBackgroundRenderer::render_page(PDFDoc * doc, int pageno) bool SplashBackgroundRenderer::render_page(PDFDoc * doc, int pageno)

View File

@ -37,7 +37,7 @@ public:
// Does this device use beginType3Char/endType3Char? Otherwise, // Does this device use beginType3Char/endType3Char? Otherwise,
// text in Type 3 fonts will be drawn with drawChar/drawString. // 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); virtual void startPage(int pageNum, GfxState *state, XRef *xrefA);

View File

@ -16,7 +16,34 @@
#include <GfxState.h> #include <GfxState.h>
#include <Stream.h> #include <Stream.h>
#include <PDFDoc.h> #include <PDFDoc.h>
#include <goo/gtypes.h>
/************ from goo/gtypes.h ***************/
// #include <goo/gtypes.h>
/*
* 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 <sys/types.h>,
* 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 <Object.h> #include <Object.h>
#include <GfxFont.h> #include <GfxFont.h>
#include <Annot.h> #include <Annot.h>
@ -58,28 +85,28 @@ struct HTMLRenderer : OutputDev
// Does this device use upside-down coordinates? // Does this device use upside-down coordinates?
// (Upside-down means (0,0) is the top left corner of the page.) // (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()? // Does this device use drawChar() or drawString()?
virtual GBool useDrawChar() { return gFalse; } virtual bool useDrawChar() { return false; }
// Does this device use functionShadedFill(), axialShadedFill(), and // Does this device use functionShadedFill(), axialShadedFill(), and
// radialShadedFill()? If this returns false, these shaded fills // radialShadedFill()? If this returns false, these shaded fills
// will be reduced to a series of other drawing operations. // 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, // Does this device use beginType3Char/endType3Char? Otherwise,
// text in Type 3 fonts will be drawn with drawChar/drawString. // 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? // 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 // Does this device need to clip pages to the crop box even when the
// box is the crop box? // 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. // Start a page.
virtual void startPage(int pageNum, GfxState *state, XRef * xref); 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 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, virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
int width, int height, int width, int height,
GfxImageColorMap *colorMap, GfxImageColorMap *colorMap,
GBool interpolate, bool interpolate,
Stream *maskStr, Stream *maskStr,
int maskWidth, int maskHeight, int maskWidth, int maskHeight,
GfxImageColorMap *maskColorMap, GfxImageColorMap *maskColorMap,
GBool maskInterpolate); bool maskInterpolate);
virtual void stroke(GfxState *state); virtual void stroke(GfxState *state);
virtual void fill(GfxState *state); virtual void fill(GfxState *state);
virtual void eoFill(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*/, GfxColorSpace * /*blendingColorSpace*/,
GBool /*isolated*/, GBool /*knockout*/, bool /*isolated*/, bool /*knockout*/,
GBool /*forSoftMask*/); bool /*forSoftMask*/);
virtual void endTransparencyGroup(GfxState * /*state*/); virtual void endTransparencyGroup(GfxState * /*state*/);
@ -319,7 +346,7 @@ protected:
// for font reencoding // for font reencoding
std::vector<int32_t> cur_mapping; std::vector<int32_t> cur_mapping;
std::vector<char*> cur_mapping2; std::vector<const char*> cur_mapping2;
std::vector<int> width_list; // width of each char std::vector<int> width_list; // width of each char
Preprocessor preprocessor; Preprocessor preprocessor;

View File

@ -56,16 +56,16 @@ void HTMLRenderer::eoFill(GfxState * state)
tracer.fill(state, true); 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? tracer.fill(state); //TODO correct?
return true; return true;
} }
void HTMLRenderer::beginTransparencyGroup(GfxState *state, double *bbox, void HTMLRenderer::beginTransparencyGroup(GfxState *state, const double *bbox,
GfxColorSpace *blendingColorSpace, GfxColorSpace *blendingColorSpace,
GBool isolated, GBool knockout, bool isolated, bool knockout,
GBool forSoftMask) { bool forSoftMask) {
inTransparencyGroup++; inTransparencyGroup++;
} }
void HTMLRenderer::endTransparencyGroup(GfxState *state) { void HTMLRenderer::endTransparencyGroup(GfxState *state) {

View File

@ -169,7 +169,7 @@ string HTMLRenderer::dump_embedded_font (GfxFont * font, FontInfo & info)
char buf[1024]; char buf[1024];
int len; int len;
while((len = obj.streamGetChars(1024, (Guchar*)buf)) > 0) while((len = obj.streamGetChars(1024, (unsigned char*)buf)) > 0)
{ {
outf.write(buf, len); 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())); auto used_map = preprocessor.get_code_map(hash_ref(font->getID()));
//calculate transformed metrics //calculate transformed metrics
double * font_bbox = font->getFontBBox(); const double * font_bbox = font->getFontBBox();
double * font_matrix = font->getFontMatrix(); const double * font_matrix = font->getFontMatrix();
double transformed_bbox[4]; double transformed_bbox[4];
memcpy(transformed_bbox, font_bbox, 4 * sizeof(double)); memcpy(transformed_bbox, font_bbox, 4 * sizeof(double));
/* /*
@ -337,7 +337,7 @@ string HTMLRenderer::dump_type3_font (GfxFont * font, FontInfo & info)
&box, nullptr); &box, nullptr);
output_dev->startDoc(cur_doc, &font_engine); output_dev->startDoc(cur_doc, &font_engine);
output_dev->startPage(1, gfx->getState(), gfx->getXRef()); output_dev->startPage(1, gfx->getState(), gfx->getXRef());
output_dev->setInType3Char(gTrue); output_dev->setInType3Char(true);
auto char_procs = ((Gfx8BitFont*)font)->getCharProcs(); auto char_procs = ((Gfx8BitFont*)font)->getCharProcs();
Object char_proc_obj; Object char_proc_obj;
auto glyph_index = cur_font->getGlyph(code, nullptr, 0); 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) if(info.use_tounicode)
{ {
int n = ctu ? int n = ctu ?
(((CharCodeToUnicode *)ctu)->mapToUnicode(cur_code, &pu)) : (((CharCodeToUnicode *)ctu)->mapToUnicode(cur_code, &pu)) :
0; 0;
u = check_unicode(pu, n, cur_code, font); u = check_unicode(pu, n, cur_code, font);
} }
else else
@ -877,7 +877,7 @@ const FontInfo * HTMLRenderer::install_font(GfxFont * font)
{ {
cerr << "Install font " << hex << new_fn_id << dec cerr << "Install font " << hex << new_fn_id << dec
<< ": (" << (font->getID()->num) << ' ' << (font->getID()->gen) << ") " << ": (" << (font->getID()->num) << ' ' << (font->getID()->gen) << ") "
<< (font->getName() ? font->getName()->getCString() : "") << (font->getName() ? font->getName()->toStr() : "")
<< endl; << endl;
} }
@ -907,7 +907,7 @@ const FontInfo * HTMLRenderer::install_font(GfxFont * font)
/* /*
* The 2nd parameter of locateFont should be true only for PS * The 2nd parameter of locateFont should be true only for PS
* which does not make much sense in our case * 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)) 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) void HTMLRenderer::install_external_font(GfxFont * font, FontInfo & info)
{ {
string fontname(font->getName()->getCString()); string fontname(font->getName()->toStr());
// resolve bad encodings in GB // resolve bad encodings in GB
auto iter = GB_ENCODED_FONT_NAME_MAP.find(fontname); 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) 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); export_remote_font(info, param.font_format, font);
delete localfontloc; delete localfontloc;
return; return;
@ -986,7 +986,7 @@ void HTMLRenderer::install_external_font(GfxFont * font, FontInfo & info)
if(localfontloc != nullptr) if(localfontloc != nullptr)
{ {
// fill in ascent/descent only, do not embed // 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; delete localfontloc;
} }
else else

View File

@ -53,7 +53,7 @@ HTMLRenderer::HTMLRenderer(Param & param)
if(!(param.debug)) if(!(param.debug))
{ {
//disable error messages of poppler //disable error messages of poppler
globalParams->setErrQuiet(gTrue); globalParams->setErrQuiet(true);
} }
ffw_init(param.debug); ffw_init(param.debug);
@ -190,7 +190,7 @@ void HTMLRenderer::process(PDFDoc *doc)
cerr << endl; cerr << endl;
} }
void HTMLRenderer::setDefaultCTM(double *ctm) void HTMLRenderer::setDefaultCTM(const double *ctm)
{ {
memcpy(default_ctm, ctm, sizeof(default_ctm)); memcpy(default_ctm, ctm, sizeof(default_ctm));
} }

View File

@ -12,7 +12,7 @@
namespace pdf2htmlEX { 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); 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, void HTMLRenderer::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
int width, int height, int width, int height,
GfxImageColorMap *colorMap, GfxImageColorMap *colorMap,
GBool interpolate, bool interpolate,
Stream *maskStr, Stream *maskStr,
int maskWidth, int maskHeight, int maskWidth, int maskHeight,
GfxImageColorMap *maskColorMap, GfxImageColorMap *maskColorMap,
GBool maskInterpolate) bool maskInterpolate)
{ {
tracer.draw_image(state); tracer.draw_image(state);

View File

@ -164,7 +164,7 @@ string HTMLRenderer::get_linkaction_str(const LinkAction * action, string & deta
{ {
auto * real_action = dynamic_cast<const LinkURI*>(action); auto * real_action = dynamic_cast<const LinkURI*>(action);
assert(real_action != nullptr); assert(real_action != nullptr);
dest_str = real_action->getURI()->getCString(); dest_str = real_action->getURI()->toStr();
} }
break; break;
case actionLaunch: case actionLaunch:

View File

@ -58,7 +58,7 @@ void HTMLRenderer::drawString(GfxState * state, const GooString * s)
// Now ready to output // Now ready to output
// get the unicodes // get the unicodes
const char *p = s->getCString(); const char *p = (s->toStr()).c_str();
int len = s->getLength(); int len = s->getLength();
//accumulated displacement of chars in this string, in text object space //accumulated displacement of chars in this string, in text object space

View File

@ -30,11 +30,11 @@ public:
void process(PDFDoc * doc); void process(PDFDoc * doc);
virtual GBool upsideDown() { return gFalse; } virtual bool upsideDown() { return false; }
virtual GBool useDrawChar() { return gTrue; } virtual bool useDrawChar() { return true; }
virtual GBool interpretType3Chars() { return gFalse; } virtual bool interpretType3Chars() { return false; }
virtual GBool needNonText() { return gFalse; } virtual bool needNonText() { return false; }
virtual GBool needClipToCropBox() { return gTrue; } virtual bool needClipToCropBox() { return true; }
virtual void drawChar(GfxState *state, double x, double y, virtual void drawChar(GfxState *state, double x, double y,
double dx, double dy, double dx, double dy,

View File

@ -438,8 +438,9 @@ int main(int argc, char **argv)
delete globalParams; delete globalParams;
// check for memory leaks // check for memory leaks
Object::memCheck(stderr); // Poppler Object class (Object.h) no longer has memCheck
gMemReport(stderr); //Object::memCheck(stderr);
//gMemReport(stderr);
exit(finished ? (EXIT_SUCCESS) : (EXIT_FAILURE)); exit(finished ? (EXIT_SUCCESS) : (EXIT_FAILURE));

View File

@ -275,7 +275,7 @@ void ffw_reencode_raw(int32 * mapping, int mapping_len, int force)
ffw_do_reencode(enc, 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)); Encoding * enc = calloc(1, sizeof(Encoding));
enc->enc_name = strcopy(""); enc->enc_name = strcopy("");

View File

@ -39,7 +39,7 @@ void ffw_close(void);
void ffw_reencode_glyph_order(void); void ffw_reencode_glyph_order(void);
void ffw_reencode_unicode_full(void); void ffw_reencode_unicode_full(void);
void ffw_reencode_raw(int32_t * mapping, int mapping_len, int force); 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); void ffw_cidflatten(void);
// add a new empty char into the font // add a new empty char into the font

View File

@ -42,7 +42,7 @@ Unicode unicode_from_font (CharCode code, GfxFont * font)
{ {
auto * font2 = dynamic_cast<Gfx8BitFont*>(font); auto * font2 = dynamic_cast<Gfx8BitFont*>(font);
assert(font2 != nullptr); assert(font2 != nullptr);
char * cname = font2->getCharName(code); const char * cname = font2->getCharName(code);
// may be untranslated ligature // may be untranslated ligature
if(cname) if(cname)
{ {