Merge remote-tracking branch 'origin/develop' into feature/pdf-link

This commit is contained in:
Svetlana Kulikova
2025-12-02 12:59:10 +03:00
607 changed files with 12948 additions and 3144 deletions

View File

@ -1662,6 +1662,7 @@ void Annot::drawText(GString *text, GString *da, int quadding, double margin,
void Annot::draw(Gfx *gfx, GBool printing) {
GBool oc, isLink;
Object annotObj, oIRTObj;
// check the flags
if ((flags & annotFlagHidden) ||
@ -1670,6 +1671,18 @@ void Annot::draw(Gfx *gfx, GBool printing) {
return;
}
if (!getObject(&annotObj)->isDict()) {
annotObj.free();
return;
}
if (type && !type->cmp("Text") && annotObj.dictLookupNF("IRT", &oIRTObj)->isRef()) {
annotObj.free(); oIRTObj.free();
return;
}
annotObj.free(); oIRTObj.free();
// check the optional content entry
if (doc->getOptionalContent()->evalOCObject(&ocObj, &oc) && !oc) {
return;

View File

@ -1528,16 +1528,16 @@ void Gfx::opSetFillColor(Object args[], int numArgs) {
" in uncolored Type 3 char or tiling pattern");
return;
}
if (numArgs != state->getFillColorSpace()->getNComps()) {
error(errSyntaxError, getPos(),
"Incorrect number of arguments in 'sc' command");
return;
}
if (out->useNameOp())
{
out->setFillColor(args, numArgs);
return;
}
if (numArgs != state->getFillColorSpace()->getNComps()) {
error(errSyntaxError, getPos(),
"Incorrect number of arguments in 'sc' command");
return;
}
state->setFillPattern(NULL);
for (i = 0; i < numArgs; ++i) {
color.c[i] = dblToCol(args[i].getNum());
@ -1554,16 +1554,16 @@ void Gfx::opSetStrokeColor(Object args[], int numArgs) {
GfxColor color;
int i;
if (numArgs != state->getStrokeColorSpace()->getNComps()) {
error(errSyntaxError, getPos(),
"Incorrect number of arguments in 'SC' command");
return;
}
if (out->useNameOp())
{
out->setStrokeColor(args, numArgs);
return;
}
if (numArgs != state->getStrokeColorSpace()->getNComps()) {
error(errSyntaxError, getPos(),
"Incorrect number of arguments in 'SC' command");
return;
}
state->setStrokePattern(NULL);
for (i = 0; i < numArgs; ++i) {
color.c[i] = dblToCol(args[i].getNum());
@ -2028,7 +2028,7 @@ void Gfx::doPatternImageMask(Object *ref, Stream *str, int width, int height,
GBool invert, GBool inlineImg, GBool interpolate) {
saveState();
out->setSoftMaskFromImageMask(state, ref, str,
out->setSoftMaskFromImageMask(state, this, ref, str,
width, height, invert, inlineImg, interpolate);
state->clearPath();
@ -4117,16 +4117,15 @@ void Gfx::opXObject(Object args[], int numArgs) {
if (out->needNonText()) {
res->lookupXObjectNF(name, &refObj);
if (out->useNameOp() && refObj.isRef())
out->drawImage(state, refObj.getRef(), name);
else
doImage(&refObj, obj1.getStream(), gFalse);
out->drawImage(state, this, refObj.getRef(), name);
doImage(&refObj, obj1.getStream(), gFalse);
refObj.free();
}
} else if (obj2.isName("Form")) {
res->lookupXObjectNF(name, &refObj);
if (out->useDrawForm() && refObj.isRef()) {
if (ocState) {
out->drawForm(state, refObj.getRef(), name);
out->drawForm(state, this, refObj.getRef(), name);
}
} else {
doForm(&refObj, &obj1);
@ -4305,7 +4304,7 @@ GBool Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
doPatternImageMask(ref, str, width, height, invert, inlineImg,
interpolate);
} else {
out->drawImageMask(state, ref, str, width, height, invert, inlineImg,
out->drawImageMask(state, this, ref, str, width, height, invert, inlineImg,
interpolate);
}
}
@ -4314,7 +4313,8 @@ GBool Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
// rendering intent
if (dict->lookup("Intent", &obj1)->isName()) {
opSetRenderingIntent(&obj1, 1);
if (!out->useNameOp())
opSetRenderingIntent(&obj1, 1);
}
obj1.free();
@ -4646,7 +4646,7 @@ GBool Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
} else {
if (haveSoftMask) {
dict->lookupNF("Mask", &maskRef);
out->drawSoftMaskedImage(state, ref, str, width, height, colorMap,
out->drawSoftMaskedImage(state, this, ref, str, width, height, colorMap,
&maskRef, maskStr, maskWidth, maskHeight,
maskColorMap,
haveMatte ? matte : (double *)NULL,
@ -4655,12 +4655,12 @@ GBool Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
delete maskColorMap;
} else if (haveExplicitMask) {
dict->lookupNF("Mask", &maskRef);
out->drawMaskedImage(state, ref, str, width, height, colorMap,
out->drawMaskedImage(state, this, ref, str, width, height, colorMap,
&maskRef, maskStr, maskWidth, maskHeight,
maskInvert, interpolate);
maskRef.free();
} else {
out->drawImage(state, ref, str, width, height, colorMap,
out->drawImage(state, this, ref, str, width, height, colorMap,
haveColorKeyMask ? maskColors : (int *)NULL, inlineImg,
interpolate);
}
@ -4932,6 +4932,12 @@ void Gfx::takeContentStreamStack(Gfx *oldGfx) {
contentStreamStack->append(oldGfx->contentStreamStack);
}
Object* Gfx::getTopContentStreamStack() {
if (!contentStreamStack->getLength())
return NULL;
return (Object*)contentStreamStack->get(contentStreamStack->getLength() - 1);
}
void Gfx::endOfPage() {
while (state->hasSaves()) {
restoreState();

View File

@ -177,6 +177,7 @@ public:
// Gfx constructor, i.e., before processing any content streams with
// the new Gfx object.
void takeContentStreamStack(Gfx *oldGfx);
Object* getTopContentStreamStack();
// Clear the state stack and the marked content stack.
void endOfPage();

View File

@ -82,7 +82,7 @@ GBool OutputDev::beginType3Char(GfxState *state, double x, double y,
return gFalse;
}
void OutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
void OutputDev::drawImageMask(GfxState *state, Gfx *gfx, Object *ref, Stream *str,
int width, int height, GBool invert,
GBool inlineImg, GBool interpolate) {
if (inlineImg) {
@ -92,14 +92,14 @@ void OutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
}
}
void OutputDev::setSoftMaskFromImageMask(GfxState *state,
void OutputDev::setSoftMaskFromImageMask(GfxState *state, Gfx *gfx,
Object *ref, Stream *str,
int width, int height, GBool invert,
GBool inlineImg, GBool interpolate) {
drawImageMask(state, ref, str, width, height, invert, inlineImg, interpolate);
drawImageMask(state, gfx, ref, str, width, height, invert, inlineImg, interpolate);
}
void OutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
void OutputDev::drawImage(GfxState *state, Gfx *gfx, Object *ref, Stream *str,
int width, int height, GfxImageColorMap *colorMap,
int *maskColors, GBool inlineImg, GBool interpolate) {
if (inlineImg) {
@ -110,24 +110,24 @@ void OutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
}
}
void OutputDev::drawMaskedImage(GfxState *state, Object *ref, Stream *str,
void OutputDev::drawMaskedImage(GfxState *state, Gfx *gfx, Object *ref, Stream *str,
int width, int height,
GfxImageColorMap *colorMap,
Object *maskRef, Stream *maskStr,
int maskWidth, int maskHeight,
GBool maskInvert, GBool interpolate) {
drawImage(state, ref, str, width, height, colorMap, NULL, gFalse,
drawImage(state, gfx, ref, str, width, height, colorMap, NULL, gFalse,
interpolate);
}
void OutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
void OutputDev::drawSoftMaskedImage(GfxState *state, Gfx *gfx, Object *ref, Stream *str,
int width, int height,
GfxImageColorMap *colorMap,
Object *maskRef, Stream *maskStr,
int maskWidth, int maskHeight,
GfxImageColorMap *maskColorMap,
double *matte, GBool interpolate) {
drawImage(state, ref, str, width, height, colorMap, NULL, gFalse,
drawImage(state, gfx, ref, str, width, height, colorMap, NULL, gFalse,
interpolate);
}

View File

@ -201,23 +201,23 @@ public:
virtual void setShading(GfxState *state, const char* name) {}
//----- image drawing
virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
virtual void drawImageMask(GfxState *state, Gfx *gfx, Object *ref, Stream *str,
int width, int height, GBool invert,
GBool inlineImg, GBool interpolate);
virtual void setSoftMaskFromImageMask(GfxState *state,
virtual void setSoftMaskFromImageMask(GfxState *state, Gfx *gfx,
Object *ref, Stream *str,
int width, int height, GBool invert,
GBool inlineImg, GBool interpolate);
virtual void drawImage(GfxState *state, Object *ref, Stream *str,
virtual void drawImage(GfxState *state, Gfx *gfx, Object *ref, Stream *str,
int width, int height, GfxImageColorMap *colorMap,
int *maskColors, GBool inlineImg, GBool interpolate);
virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
virtual void drawMaskedImage(GfxState *state, Gfx *gfx, Object *ref, Stream *str,
int width, int height,
GfxImageColorMap *colorMap,
Object *maskRef, Stream *maskStr,
int maskWidth, int maskHeight,
GBool maskInvert, GBool interpolate);
virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
virtual void drawSoftMaskedImage(GfxState *state, Gfx *gfx, Object *ref, Stream *str,
int width, int height,
GfxImageColorMap *colorMap,
Object *maskRef, Stream *maskStr,
@ -237,8 +237,8 @@ public:
double llx, double lly, double urx, double ury) {}
//----- form XObjects
virtual void drawForm(GfxState *state, Ref id, const char *name = nullptr) {}
virtual void drawImage(GfxState *pGState, Ref id, const char* name = nullptr) {}
virtual void drawForm(GfxState *state, Gfx *gfx, Ref id, const char *name = nullptr) {}
virtual void drawImage(GfxState *pGState, Gfx *gfx, Ref id, const char* name = nullptr) {}
//----- PostScript XObjects
virtual void psXObject(Stream *psStream, Stream *level1Stream) {}