"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xpdf/Gfx.cc" between
xpdf-4.01.01.tar.gz and xpdf-4.02.tar.gz

About: Xpdf is a PDF viewer for X.

Gfx.cc  (xpdf-4.01.01):Gfx.cc  (xpdf-4.02)
skipping to change at line 922 skipping to change at line 922
state->setLineDash(dash, length, args[1].getNum()); state->setLineDash(dash, length, args[1].getNum());
out->updateLineDash(state); out->updateLineDash(state);
} }
void Gfx::opSetFlat(Object args[], int numArgs) { void Gfx::opSetFlat(Object args[], int numArgs) {
state->setFlatness((int)args[0].getNum()); state->setFlatness((int)args[0].getNum());
out->updateFlatness(state); out->updateFlatness(state);
} }
void Gfx::opSetLineJoin(Object args[], int numArgs) { void Gfx::opSetLineJoin(Object args[], int numArgs) {
state->setLineJoin(args[0].getInt()); int lineJoin;
lineJoin = args[0].getInt();
if (lineJoin < 0 || lineJoin > 2) {
lineJoin = 0;
}
state->setLineJoin(lineJoin);
out->updateLineJoin(state); out->updateLineJoin(state);
} }
void Gfx::opSetLineCap(Object args[], int numArgs) { void Gfx::opSetLineCap(Object args[], int numArgs) {
state->setLineCap(args[0].getInt()); int lineCap;
lineCap = args[0].getInt();
if (lineCap < 0 || lineCap > 2) {
lineCap = 0;
}
state->setLineCap(lineCap);
out->updateLineCap(state); out->updateLineCap(state);
} }
void Gfx::opSetMiterLimit(Object args[], int numArgs) { void Gfx::opSetMiterLimit(Object args[], int numArgs) {
state->setMiterLimit(args[0].getNum()); state->setMiterLimit(args[0].getNum());
out->updateMiterLimit(state); out->updateMiterLimit(state);
} }
void Gfx::opSetLineWidth(Object args[], int numArgs) { void Gfx::opSetLineWidth(Object args[], int numArgs) {
state->setLineWidth(args[0].getNum()); state->setLineWidth(args[0].getNum());
skipping to change at line 1044 skipping to change at line 1056
obj2.free(); obj2.free();
if (obj1.dictLookup("CA", &obj2)->isNum()) { if (obj1.dictLookup("CA", &obj2)->isNum()) {
opac = obj2.getNum(); opac = obj2.getNum();
state->setStrokeOpacity(opac < 0 ? 0 : opac > 1 ? 1 : opac); state->setStrokeOpacity(opac < 0 ? 0 : opac > 1 ? 1 : opac);
out->updateStrokeOpacity(state); out->updateStrokeOpacity(state);
} }
obj2.free(); obj2.free();
// fill/stroke overprint, overprint mode // fill/stroke overprint, overprint mode
if ((haveFillOP = (obj1.dictLookup("op", &obj2)->isBool()))) { if ((haveFillOP = (obj1.dictLookup("op", &obj2)->isBool()))) {
if (!state->getInCachedT3Char()) { if (!state->getIgnoreColorOps()) {
state->setFillOverprint(obj2.getBool()); state->setFillOverprint(obj2.getBool());
out->updateFillOverprint(state); out->updateFillOverprint(state);
} else { } else {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring overprint setting"
"Ignoring overprint setting in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
} }
} }
obj2.free(); obj2.free();
if (obj1.dictLookup("OP", &obj2)->isBool()) { if (obj1.dictLookup("OP", &obj2)->isBool()) {
if (!state->getInCachedT3Char()) { if (!state->getIgnoreColorOps()) {
state->setStrokeOverprint(obj2.getBool()); state->setStrokeOverprint(obj2.getBool());
out->updateStrokeOverprint(state); out->updateStrokeOverprint(state);
if (!haveFillOP) { if (!haveFillOP) {
state->setFillOverprint(obj2.getBool()); state->setFillOverprint(obj2.getBool());
out->updateFillOverprint(state); out->updateFillOverprint(state);
} }
} else { } else {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring overprint setting"
"Ignoring overprint setting in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
} }
} }
obj2.free(); obj2.free();
if (obj1.dictLookup("OPM", &obj2)->isInt()) { if (obj1.dictLookup("OPM", &obj2)->isInt()) {
if (!state->getInCachedT3Char()) { if (!state->getIgnoreColorOps()) {
state->setOverprintMode(obj2.getInt()); state->setOverprintMode(obj2.getInt());
out->updateOverprintMode(state); out->updateOverprintMode(state);
} else { } else {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring overprint setting"
"Ignoring overprint setting in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
} }
} }
obj2.free(); obj2.free();
// stroke adjust // stroke adjust
if (obj1.dictLookup("SA", &obj2)->isBool()) { if (obj1.dictLookup("SA", &obj2)->isBool()) {
state->setStrokeAdjust(obj2.getBool()); state->setStrokeAdjust(obj2.getBool());
out->updateStrokeAdjust(state); out->updateStrokeAdjust(state);
} }
obj2.free(); obj2.free();
// transfer function // transfer function
if (obj1.dictLookup("TR2", &obj2)->isNull()) { if (obj1.dictLookup("TR2", &obj2)->isNull()) {
obj2.free(); obj2.free();
obj1.dictLookup("TR", &obj2); obj1.dictLookup("TR", &obj2);
} }
if (!obj2.isNull()) { if (!obj2.isNull()) {
if (!state->getInCachedT3Char()) { if (!state->getIgnoreColorOps()) {
if (obj2.isName("Default") || if (obj2.isName("Default") ||
obj2.isName("Identity")) { obj2.isName("Identity")) {
funcs[0] = funcs[1] = funcs[2] = funcs[3] = NULL; funcs[0] = funcs[1] = funcs[2] = funcs[3] = NULL;
state->setTransfer(funcs); state->setTransfer(funcs);
out->updateTransfer(state); out->updateTransfer(state);
} else if (obj2.isArray() && obj2.arrayGetLength() == 4) { } else if (obj2.isArray() && obj2.arrayGetLength() == 4) {
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
obj2.arrayGet(i, &obj3); obj2.arrayGet(i, &obj3);
funcs[i] = Function::parse(&obj3); funcs[i] = Function::parse(&obj3, 1, 1);
obj3.free(); obj3.free();
if (!funcs[i]) { if (!funcs[i]) {
break; break;
} }
} }
if (i == 4) { if (i == 4) {
state->setTransfer(funcs); state->setTransfer(funcs);
out->updateTransfer(state); out->updateTransfer(state);
} }
} else if (obj2.isName() || obj2.isDict() || obj2.isStream()) { } else if (obj2.isName() || obj2.isDict() || obj2.isStream()) {
if ((funcs[0] = Function::parse(&obj2))) { if ((funcs[0] = Function::parse(&obj2, 1, 1))) {
funcs[1] = funcs[2] = funcs[3] = NULL; funcs[1] = funcs[2] = funcs[3] = NULL;
state->setTransfer(funcs); state->setTransfer(funcs);
out->updateTransfer(state); out->updateTransfer(state);
} }
} else { } else {
error(errSyntaxError, getPos(), error(errSyntaxError, getPos(),
"Invalid transfer function in ExtGState"); "Invalid transfer function in ExtGState");
} }
} else { } else {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring transfer function setting"
"Ignoring transfer function setting in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
} }
} }
obj2.free(); obj2.free();
// soft mask // soft mask
if (!obj1.dictLookup("SMask", &obj2)->isNull()) { if (!obj1.dictLookup("SMask", &obj2)->isNull()) {
if (obj2.isName("None")) { if (obj2.isName("None")) {
out->clearSoftMask(state); out->clearSoftMask(state);
} else if (obj2.isDict()) { } else if (obj2.isDict()) {
if (obj2.dictLookup("S", &obj3)->isName("Alpha")) { obj2.dictLookup("S", &obj3);
if (obj3.isName("Alpha")) {
alpha = gTrue; alpha = gTrue;
} else { // "Luminosity" } else if (obj3.isName("Luminosity")) {
alpha = gFalse;
} else {
error(errSyntaxError, getPos(),
"Missing S (subtype) entry in soft mask");
alpha = gFalse; alpha = gFalse;
} }
obj3.free(); obj3.free();
funcs[0] = NULL; funcs[0] = NULL;
if (!obj2.dictLookup("TR", &obj3)->isNull()) { if (!obj2.dictLookup("TR", &obj3)->isNull()) {
if (obj3.isName("Default") || if (obj3.isName("Default") ||
obj3.isName("Identity")) { obj3.isName("Identity")) {
funcs[0] = NULL; funcs[0] = NULL;
} else { } else {
funcs[0] = Function::parse(&obj3); if (!(funcs[0] = Function::parse(&obj3, 1, 1))) {
if (funcs[0]->getInputSize() != 1 ||
funcs[0]->getOutputSize() != 1) {
error(errSyntaxError, getPos(), error(errSyntaxError, getPos(),
"Invalid transfer function in soft mask in ExtGState"); "Invalid transfer function in soft mask in ExtGState");
delete funcs[0]; delete funcs[0];
funcs[0] = NULL; funcs[0] = NULL;
} }
} }
} }
obj3.free(); obj3.free();
if ((haveBackdropColor = obj2.dictLookup("BC", &obj3)->isArray())) { if ((haveBackdropColor = obj2.dictLookup("BC", &obj3)->isArray())) {
for (i = 0; i < gfxColorMaxComps; ++i) { for (i = 0; i < gfxColorMaxComps; ++i) {
skipping to change at line 1293 skipping to change at line 1308
if (blendingColorSpace) { if (blendingColorSpace) {
delete blendingColorSpace; delete blendingColorSpace;
} }
obj1.free(); obj1.free();
} }
void Gfx::opSetRenderingIntent(Object args[], int numArgs) { void Gfx::opSetRenderingIntent(Object args[], int numArgs) {
GfxRenderingIntent ri; GfxRenderingIntent ri;
if (state->getInCachedT3Char()) { if (state->getIgnoreColorOps()) {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring rendering intent setting"
"Ignoring rendering intent setting in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
return; return;
} }
ri = parseRenderingIntent(args[0].getName()); ri = parseRenderingIntent(args[0].getName());
state->setRenderingIntent(ri); state->setRenderingIntent(ri);
out->updateRenderingIntent(state); out->updateRenderingIntent(state);
} }
GfxRenderingIntent Gfx::parseRenderingIntent(const char *name) { GfxRenderingIntent Gfx::parseRenderingIntent(const char *name) {
if (!strcmp(name, "AbsoluteColorimetric")) { if (!strcmp(name, "AbsoluteColorimetric")) {
return gfxRenderingIntentAbsoluteColorimetric; return gfxRenderingIntentAbsoluteColorimetric;
skipping to change at line 1323 skipping to change at line 1338
return gfxRenderingIntentRelativeColorimetric; return gfxRenderingIntentRelativeColorimetric;
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// color operators // color operators
//------------------------------------------------------------------------ //------------------------------------------------------------------------
void Gfx::opSetFillGray(Object args[], int numArgs) { void Gfx::opSetFillGray(Object args[], int numArgs) {
GfxColor color; GfxColor color;
if (state->getInCachedT3Char()) { if (state->getIgnoreColorOps()) {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring color setting"
"Ignoring color setting in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
return; return;
} }
state->setFillPattern(NULL); state->setFillPattern(NULL);
state->setFillColorSpace(GfxColorSpace::create(csDeviceGray)); state->setFillColorSpace(GfxColorSpace::create(csDeviceGray));
out->updateFillColorSpace(state); out->updateFillColorSpace(state);
color.c[0] = dblToCol(args[0].getNum()); color.c[0] = dblToCol(args[0].getNum());
state->setFillColor(&color); state->setFillColor(&color);
out->updateFillColor(state); out->updateFillColor(state);
} }
void Gfx::opSetStrokeGray(Object args[], int numArgs) { void Gfx::opSetStrokeGray(Object args[], int numArgs) {
GfxColor color; GfxColor color;
if (state->getInCachedT3Char()) { if (state->getIgnoreColorOps()) {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring color setting"
"Ignoring color setting in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
return; return;
} }
state->setStrokePattern(NULL); state->setStrokePattern(NULL);
state->setStrokeColorSpace(GfxColorSpace::create(csDeviceGray)); state->setStrokeColorSpace(GfxColorSpace::create(csDeviceGray));
out->updateStrokeColorSpace(state); out->updateStrokeColorSpace(state);
color.c[0] = dblToCol(args[0].getNum()); color.c[0] = dblToCol(args[0].getNum());
state->setStrokeColor(&color); state->setStrokeColor(&color);
out->updateStrokeColor(state); out->updateStrokeColor(state);
} }
void Gfx::opSetFillCMYKColor(Object args[], int numArgs) { void Gfx::opSetFillCMYKColor(Object args[], int numArgs) {
GfxColor color; GfxColor color;
int i; int i;
if (state->getInCachedT3Char()) { if (state->getIgnoreColorOps()) {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring color setting"
"Ignoring color setting in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
return; return;
} }
state->setFillPattern(NULL); state->setFillPattern(NULL);
state->setFillColorSpace(GfxColorSpace::create(csDeviceCMYK)); state->setFillColorSpace(GfxColorSpace::create(csDeviceCMYK));
out->updateFillColorSpace(state); out->updateFillColorSpace(state);
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
color.c[i] = dblToCol(args[i].getNum()); color.c[i] = dblToCol(args[i].getNum());
} }
state->setFillColor(&color); state->setFillColor(&color);
out->updateFillColor(state); out->updateFillColor(state);
} }
void Gfx::opSetStrokeCMYKColor(Object args[], int numArgs) { void Gfx::opSetStrokeCMYKColor(Object args[], int numArgs) {
GfxColor color; GfxColor color;
int i; int i;
if (state->getInCachedT3Char()) { if (state->getIgnoreColorOps()) {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring color setting"
"Ignoring color setting in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
return; return;
} }
state->setStrokePattern(NULL); state->setStrokePattern(NULL);
state->setStrokeColorSpace(GfxColorSpace::create(csDeviceCMYK)); state->setStrokeColorSpace(GfxColorSpace::create(csDeviceCMYK));
out->updateStrokeColorSpace(state); out->updateStrokeColorSpace(state);
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
color.c[i] = dblToCol(args[i].getNum()); color.c[i] = dblToCol(args[i].getNum());
} }
state->setStrokeColor(&color); state->setStrokeColor(&color);
out->updateStrokeColor(state); out->updateStrokeColor(state);
} }
void Gfx::opSetFillRGBColor(Object args[], int numArgs) { void Gfx::opSetFillRGBColor(Object args[], int numArgs) {
GfxColor color; GfxColor color;
int i; int i;
if (state->getInCachedT3Char()) { if (state->getIgnoreColorOps()) {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring color setting"
"Ignoring color setting in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
return; return;
} }
state->setFillPattern(NULL); state->setFillPattern(NULL);
state->setFillColorSpace(GfxColorSpace::create(csDeviceRGB)); state->setFillColorSpace(GfxColorSpace::create(csDeviceRGB));
out->updateFillColorSpace(state); out->updateFillColorSpace(state);
for (i = 0; i < 3; ++i) { for (i = 0; i < 3; ++i) {
color.c[i] = dblToCol(args[i].getNum()); color.c[i] = dblToCol(args[i].getNum());
} }
state->setFillColor(&color); state->setFillColor(&color);
out->updateFillColor(state); out->updateFillColor(state);
} }
void Gfx::opSetStrokeRGBColor(Object args[], int numArgs) { void Gfx::opSetStrokeRGBColor(Object args[], int numArgs) {
GfxColor color; GfxColor color;
int i; int i;
if (state->getInCachedT3Char()) { if (state->getIgnoreColorOps()) {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring color setting"
"Ignoring color setting in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
return; return;
} }
state->setStrokePattern(NULL); state->setStrokePattern(NULL);
state->setStrokeColorSpace(GfxColorSpace::create(csDeviceRGB)); state->setStrokeColorSpace(GfxColorSpace::create(csDeviceRGB));
out->updateStrokeColorSpace(state); out->updateStrokeColorSpace(state);
for (i = 0; i < 3; ++i) { for (i = 0; i < 3; ++i) {
color.c[i] = dblToCol(args[i].getNum()); color.c[i] = dblToCol(args[i].getNum());
} }
state->setStrokeColor(&color); state->setStrokeColor(&color);
out->updateStrokeColor(state); out->updateStrokeColor(state);
} }
void Gfx::opSetFillColorSpace(Object args[], int numArgs) { void Gfx::opSetFillColorSpace(Object args[], int numArgs) {
Object obj; Object obj;
GfxColorSpace *colorSpace; GfxColorSpace *colorSpace;
GfxColor color; GfxColor color;
if (state->getInCachedT3Char()) { if (state->getIgnoreColorOps()) {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring color space setting"
"Ignoring color space setting in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
return; return;
} }
state->setFillPattern(NULL); state->setFillPattern(NULL);
res->lookupColorSpace(args[0].getName(), &obj); res->lookupColorSpace(args[0].getName(), &obj);
if (obj.isNull()) { if (obj.isNull()) {
colorSpace = GfxColorSpace::parse(&args[0] colorSpace = GfxColorSpace::parse(&args[0]
); );
} else { } else {
colorSpace = GfxColorSpace::parse(&obj colorSpace = GfxColorSpace::parse(&obj
); );
skipping to change at line 1464 skipping to change at line 1479
} else { } else {
error(errSyntaxError, getPos(), "Bad color space (fill)"); error(errSyntaxError, getPos(), "Bad color space (fill)");
} }
} }
void Gfx::opSetStrokeColorSpace(Object args[], int numArgs) { void Gfx::opSetStrokeColorSpace(Object args[], int numArgs) {
Object obj; Object obj;
GfxColorSpace *colorSpace; GfxColorSpace *colorSpace;
GfxColor color; GfxColor color;
if (state->getInCachedT3Char()) { if (state->getIgnoreColorOps()) {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring color space setting"
"Ignoring color space setting in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
return; return;
} }
state->setStrokePattern(NULL); state->setStrokePattern(NULL);
res->lookupColorSpace(args[0].getName(), &obj); res->lookupColorSpace(args[0].getName(), &obj);
if (obj.isNull()) { if (obj.isNull()) {
colorSpace = GfxColorSpace::parse(&args[0] colorSpace = GfxColorSpace::parse(&args[0]
); );
} else { } else {
colorSpace = GfxColorSpace::parse(&obj colorSpace = GfxColorSpace::parse(&obj
); );
skipping to change at line 1494 skipping to change at line 1509
out->updateStrokeColor(state); out->updateStrokeColor(state);
} else { } else {
error(errSyntaxError, getPos(), "Bad color space (stroke)"); error(errSyntaxError, getPos(), "Bad color space (stroke)");
} }
} }
void Gfx::opSetFillColor(Object args[], int numArgs) { void Gfx::opSetFillColor(Object args[], int numArgs) {
GfxColor color; GfxColor color;
int i; int i;
if (state->getInCachedT3Char()) { if (state->getIgnoreColorOps()) {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring color setting"
"Ignoring color setting in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
return; return;
} }
if (numArgs != state->getFillColorSpace()->getNComps()) { if (numArgs != state->getFillColorSpace()->getNComps()) {
error(errSyntaxError, getPos(), error(errSyntaxError, getPos(),
"Incorrect number of arguments in 'sc' command"); "Incorrect number of arguments in 'sc' command");
return; return;
} }
state->setFillPattern(NULL); state->setFillPattern(NULL);
for (i = 0; i < numArgs; ++i) { for (i = 0; i < numArgs; ++i) {
color.c[i] = dblToCol(args[i].getNum()); color.c[i] = dblToCol(args[i].getNum());
skipping to change at line 1534 skipping to change at line 1549
} }
state->setStrokeColor(&color); state->setStrokeColor(&color);
out->updateStrokeColor(state); out->updateStrokeColor(state);
} }
void Gfx::opSetFillColorN(Object args[], int numArgs) { void Gfx::opSetFillColorN(Object args[], int numArgs) {
GfxColor color; GfxColor color;
GfxPattern *pattern; GfxPattern *pattern;
int i; int i;
if (state->getInCachedT3Char()) { if (state->getIgnoreColorOps()) {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring color setting"
"Ignoring color setting in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
return; return;
} }
if (state->getFillColorSpace()->getMode() == csPattern) { if (state->getFillColorSpace()->getMode() == csPattern) {
if (numArgs == 0 || !args[numArgs-1].isName()) { if (numArgs == 0 || !args[numArgs-1].isName()) {
error(errSyntaxError, getPos(), error(errSyntaxError, getPos(),
"Invalid arguments in 'scn' command"); "Invalid arguments in 'scn' command");
return; return;
} }
if (numArgs > 1) { if (numArgs > 1) {
if (!((GfxPatternColorSpace *)state->getFillColorSpace())->getUnder() || if (!((GfxPatternColorSpace *)state->getFillColorSpace())->getUnder() ||
skipping to change at line 1588 skipping to change at line 1603
state->setFillColor(&color); state->setFillColor(&color);
out->updateFillColor(state); out->updateFillColor(state);
} }
} }
void Gfx::opSetStrokeColorN(Object args[], int numArgs) { void Gfx::opSetStrokeColorN(Object args[], int numArgs) {
GfxColor color; GfxColor color;
GfxPattern *pattern; GfxPattern *pattern;
int i; int i;
if (state->getInCachedT3Char()) { if (state->getIgnoreColorOps()) {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring color setting"
"Ignoring color setting in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
return; return;
} }
if (state->getStrokeColorSpace()->getMode() == csPattern) { if (state->getStrokeColorSpace()->getMode() == csPattern) {
if (numArgs == 0 || !args[numArgs-1].isName()) { if (numArgs == 0 || !args[numArgs-1].isName()) {
error(errSyntaxError, getPos(), error(errSyntaxError, getPos(),
"Invalid arguments in 'SCN' command"); "Invalid arguments in 'SCN' command");
return; return;
} }
if (numArgs > 1) { if (numArgs > 1) {
if (!((GfxPatternColorSpace *)state->getStrokeColorSpace()) if (!((GfxPatternColorSpace *)state->getStrokeColorSpace())
skipping to change at line 2071 skipping to change at line 2086
state->setFillPattern(NULL); state->setFillPattern(NULL);
state->setStrokePattern(NULL); state->setStrokePattern(NULL);
if (tPat->getPaintType() == 2 && (cs = patCS->getUnder())) { if (tPat->getPaintType() == 2 && (cs = patCS->getUnder())) {
state->setFillColorSpace(cs->copy()); state->setFillColorSpace(cs->copy());
out->updateFillColorSpace(state); out->updateFillColorSpace(state);
state->setStrokeColorSpace(cs->copy()); state->setStrokeColorSpace(cs->copy());
out->updateStrokeColorSpace(state); out->updateStrokeColorSpace(state);
state->setStrokeColor(state->getFillColor()); state->setStrokeColor(state->getFillColor());
out->updateFillColor(state); out->updateFillColor(state);
out->updateStrokeColor(state); out->updateStrokeColor(state);
state->setIgnoreColorOps(gTrue);
} else { } else {
state->setFillColorSpace(GfxColorSpace::create(csDeviceGray)); state->setFillColorSpace(GfxColorSpace::create(csDeviceGray));
out->updateFillColorSpace(state); out->updateFillColorSpace(state);
state->getFillColorSpace()->getDefaultColor(&color); state->getFillColorSpace()->getDefaultColor(&color);
state->setFillColor(&color); state->setFillColor(&color);
out->updateFillColor(state); out->updateFillColor(state);
state->setStrokeColorSpace(GfxColorSpace::create(csDeviceGray)); state->setStrokeColorSpace(GfxColorSpace::create(csDeviceGray));
out->updateStrokeColorSpace(state); out->updateStrokeColorSpace(state);
state->getStrokeColorSpace()->getDefaultColor(&color); state->getStrokeColorSpace()->getDefaultColor(&color);
state->setStrokeColor(&color); state->setStrokeColor(&color);
skipping to change at line 2226 skipping to change at line 2242
shading = sPat->getShading(); shading = sPat->getShading();
// save current graphics state // save current graphics state
savedState = saveStateStack(); savedState = saveStateStack();
// clip to current path // clip to current path
if (stroke) { if (stroke) {
state->clipToStrokePath(); state->clipToStrokePath();
out->clipToStrokePath(state); out->clipToStrokePath(state);
state->setFillOverprint(state->getStrokeOverprint());
} else if (!text) { } else if (!text) {
state->clip(); state->clip();
if (eoFill) { if (eoFill) {
out->eoClip(state); out->eoClip(state);
} else { } else {
out->clip(state); out->clip(state);
} }
} }
state->clearPath(); state->clearPath();
// construct a (pattern space) -> (current space) transform matrix // construct a (pattern space) -> (current space) transform matrix
ctm = state->getCTM(); ctm = state->getCTM();
btm = baseMatrix; btm = baseMatrix;
ptm = sPat->getMatrix(); ptm = sPat->getMatrix();
// iCTM = invert CTM // iCTM = invert CTM
det = ctm[0] * ctm[3] - ctm[1] * ctm[2]; det = ctm[0] * ctm[3] - ctm[1] * ctm[2];
if (fabs(det) <= 1e-10) { if (fabs(det) <= 1e-10) {
error(errSyntaxError, getPos(), "Singular matrix in shading pattern fill"); error(errSyntaxError, getPos(), "Singular matrix in shading pattern fill");
restoreStateStack(savedState);
return; return;
} }
det = 1 / det; det = 1 / det;
ictm[0] = ctm[3] * det; ictm[0] = ctm[3] * det;
ictm[1] = -ctm[1] * det; ictm[1] = -ctm[1] * det;
ictm[2] = -ctm[2] * det; ictm[2] = -ctm[2] * det;
ictm[3] = ctm[0] * det; ictm[3] = ctm[0] * det;
ictm[4] = (ctm[2] * ctm[5] - ctm[3] * ctm[4]) * det; ictm[4] = (ctm[2] * ctm[5] - ctm[3] * ctm[4]) * det;
ictm[5] = (ctm[1] * ctm[4] - ctm[0] * ctm[5]) * det; ictm[5] = (ctm[1] * ctm[4] - ctm[0] * ctm[5]) * det;
// m1 = PTM * BTM = PTM * base transform matrix // m1 = PTM * BTM = PTM * base transform matrix
skipping to change at line 2341 skipping to change at line 2359
// restore graphics state // restore graphics state
restoreStateStack(savedState); restoreStateStack(savedState);
} }
void Gfx::opShFill(Object args[], int numArgs) { void Gfx::opShFill(Object args[], int numArgs) {
GfxShading *shading; GfxShading *shading;
GfxState *savedState; GfxState *savedState;
double xMin, yMin, xMax, yMax; double xMin, yMin, xMax, yMax;
if (state->getInCachedT3Char()) { if (state->getIgnoreColorOps()) {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring shaded fill"
"Ignoring shaded fill in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
return; return;
} }
if (!out->needNonText()) { if (!out->needNonText()) {
return; return;
} }
if (!ocState) { if (!ocState) {
return; return;
} }
skipping to change at line 4126 skipping to change at line 4144
} catch (GMemException e) { } catch (GMemException e) {
obj1.free(); obj1.free();
throw; throw;
} }
#endif #endif
obj1.free(); obj1.free();
ocState = ocSaved; ocState = ocSaved;
} }
void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { GBool Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) {
Dict *dict, *maskDict; Dict *dict, *maskDict;
int width, height; int width, height;
int bits, maskBits; int bits, maskBits;
StreamColorSpaceMode csMode; StreamColorSpaceMode csMode;
GBool mask, invert; GBool mask, invert;
GfxColorSpace *colorSpace, *maskColorSpace; GfxColorSpace *colorSpace, *maskColorSpace;
GfxImageColorMap *colorMap, *maskColorMap; GfxImageColorMap *colorMap, *maskColorMap;
Object maskObj, smaskObj; Object maskObj, smaskObj;
GBool haveColorKeyMask, haveExplicitMask, haveSoftMask, haveMatte; GBool haveColorKeyMask, haveExplicitMask, haveSoftMask, haveMatte;
int maskColors[2*gfxColorMaxComps]; int maskColors[2*gfxColorMaxComps];
skipping to change at line 4148 skipping to change at line 4166
GBool maskInvert; GBool maskInvert;
Stream *maskStr; Stream *maskStr;
double matte[gfxColorMaxComps]; double matte[gfxColorMaxComps];
GBool interpolate; GBool interpolate;
GfxRenderingIntent riSaved; GfxRenderingIntent riSaved;
Object obj1, obj2; Object obj1, obj2;
int i, n; int i, n;
// check for optional content // check for optional content
if (!ocState && !inlineImg) { if (!ocState && !inlineImg) {
return; return gTrue;
} }
// get info from the stream // get info from the stream
bits = 0; bits = 0;
csMode = streamCSNone; csMode = streamCSNone;
str->getImageParams(&bits, &csMode); str->getImageParams(&bits, &csMode);
// get stream dict // get stream dict
dict = str->getDict(); dict = str->getDict();
skipping to change at line 4312 skipping to change at line 4330
colorSpace = GfxColorSpace::create(csDeviceRGB); colorSpace = GfxColorSpace::create(csDeviceRGB);
} else if (csMode == streamCSDeviceCMYK) { } else if (csMode == streamCSDeviceCMYK) {
colorSpace = GfxColorSpace::create(csDeviceCMYK); colorSpace = GfxColorSpace::create(csDeviceCMYK);
} else { } else {
colorSpace = NULL; colorSpace = NULL;
} }
obj1.free(); obj1.free();
if (!colorSpace) { if (!colorSpace) {
goto err1; goto err1;
} }
if (colorSpace->getMode() == csPattern) {
error(errSyntaxError, getPos(), "Image with a Pattern color space");
delete colorSpace;
goto err1;
}
dict->lookup("Decode", &obj1); dict->lookup("Decode", &obj1);
if (obj1.isNull()) { if (obj1.isNull()) {
obj1.free(); obj1.free();
dict->lookup("D", &obj1); dict->lookup("D", &obj1);
} }
colorMap = new GfxImageColorMap(bits, &obj1, colorSpace); colorMap = new GfxImageColorMap(bits, &obj1, colorSpace);
obj1.free(); obj1.free();
if (!colorMap->isOk()) { if (!colorMap->isOk()) {
delete colorMap; delete colorMap;
goto err1; goto err1;
skipping to change at line 4368 skipping to change at line 4391
maskDict->lookup("H", &obj1); maskDict->lookup("H", &obj1);
} }
if (!obj1.isInt()) { if (!obj1.isInt()) {
delete colorMap; delete colorMap;
maskObj.free(); maskObj.free();
smaskObj.free(); smaskObj.free();
goto err2; goto err2;
} }
maskHeight = obj1.getInt(); maskHeight = obj1.getInt();
obj1.free(); obj1.free();
if (maskWidth <= 0 || maskHeight <= 0) {
delete colorMap;
maskObj.free();
smaskObj.free();
goto err1;
}
maskDict->lookup("BitsPerComponent", &obj1); maskDict->lookup("BitsPerComponent", &obj1);
if (obj1.isNull()) { if (obj1.isNull()) {
obj1.free(); obj1.free();
maskDict->lookup("BPC", &obj1); maskDict->lookup("BPC", &obj1);
} }
if (!obj1.isInt()) { if (!obj1.isInt()) {
delete colorMap; delete colorMap;
maskObj.free(); maskObj.free();
smaskObj.free(); smaskObj.free();
goto err2; goto err2;
} }
maskBits = obj1.getInt(); maskBits = obj1.getInt();
obj1.free(); obj1.free();
if (maskBits < 1 || maskBits > 16) {
delete colorMap;
maskObj.free();
smaskObj.free();
goto err1;
}
maskDict->lookup("ColorSpace", &obj1); maskDict->lookup("ColorSpace", &obj1);
if (obj1.isNull()) { if (obj1.isNull()) {
obj1.free(); obj1.free();
maskDict->lookup("CS", &obj1); maskDict->lookup("CS", &obj1);
} }
if (obj1.isName()) { if (obj1.isName()) {
res->lookupColorSpace(obj1.getName(), &obj2); res->lookupColorSpace(obj1.getName(), &obj2);
if (!obj2.isNull()) { if (!obj2.isNull()) {
obj1.free(); obj1.free();
obj1 = obj2; obj1 = obj2;
skipping to change at line 4504 skipping to change at line 4539
maskDict->lookup("H", &obj1); maskDict->lookup("H", &obj1);
} }
if (!obj1.isInt()) { if (!obj1.isInt()) {
delete colorMap; delete colorMap;
maskObj.free(); maskObj.free();
smaskObj.free(); smaskObj.free();
goto err2; goto err2;
} }
maskHeight = obj1.getInt(); maskHeight = obj1.getInt();
obj1.free(); obj1.free();
if (maskWidth <= 0 || maskHeight <= 0) {
delete colorMap;
maskObj.free();
smaskObj.free();
goto err2;
}
maskDict->lookup("ImageMask", &obj1); maskDict->lookup("ImageMask", &obj1);
if (obj1.isNull()) { if (obj1.isNull()) {
obj1.free(); obj1.free();
maskDict->lookup("IM", &obj1); maskDict->lookup("IM", &obj1);
} }
if (!obj1.isBool() || !obj1.getBool()) { if (!obj1.isBool() || !obj1.getBool()) {
delete colorMap; delete colorMap;
maskObj.free(); maskObj.free();
smaskObj.free(); smaskObj.free();
goto err2; goto err2;
skipping to change at line 4537 skipping to change at line 4578
delete colorMap; delete colorMap;
maskObj.free(); maskObj.free();
smaskObj.free(); smaskObj.free();
goto err2; goto err2;
} }
obj1.free(); obj1.free();
haveExplicitMask = gTrue; haveExplicitMask = gTrue;
} }
// if drawing is disabled, skip over inline image data // if drawing is disabled, skip over inline image data
if (state->getInCachedT3Char() || !ocState) { if (state->getIgnoreColorOps() || !ocState) {
if (state->getInCachedT3Char()) { if (state->getIgnoreColorOps()) {
error(errSyntaxWarning, getPos(), error(errSyntaxWarning, getPos(), "Ignoring image"
"Ignoring image in cached Type 3 character"); " in uncolored Type 3 char or tiling pattern");
} }
if (inlineImg) { if (inlineImg) {
str->reset(); str->reset();
n = height * ((width * colorMap->getNumPixelComps() * n = height * ((width * colorMap->getNumPixelComps() *
colorMap->getBits() + 7) / 8); colorMap->getBits() + 7) / 8);
str->discardChars(n); str->discardChars(n);
str->close(); str->close();
} }
// draw it // draw it
skipping to change at line 4585 skipping to change at line 4626
if (state->getRenderingIntent() != riSaved) { if (state->getRenderingIntent() != riSaved) {
state->setRenderingIntent(riSaved); state->setRenderingIntent(riSaved);
out->updateRenderingIntent(state); out->updateRenderingIntent(state);
} }
if ((i = width * height) > 1000) { if ((i = width * height) > 1000) {
i = 1000; i = 1000;
} }
opCounter += i; opCounter += i;
return; return gTrue;
err2: err2:
obj1.free(); obj1.free();
err1: err1:
error(errSyntaxError, getPos(), "Bad image parameters"); error(errSyntaxError, getPos(), "Bad image parameters");
// restore rendering intent // restore rendering intent
if (state->getRenderingIntent() != riSaved) { if (state->getRenderingIntent() != riSaved) {
state->setRenderingIntent(riSaved); state->setRenderingIntent(riSaved);
out->updateRenderingIntent(state); out->updateRenderingIntent(state);
} }
return gFalse;
} }
void Gfx::doForm(Object *strRef, Object *str) { void Gfx::doForm(Object *strRef, Object *str) {
Dict *dict; Dict *dict;
GBool transpGroup, isolated, knockout; GBool transpGroup, isolated, knockout;
GfxColorSpace *blendingColorSpace; GfxColorSpace *blendingColorSpace;
Object matrixObj, bboxObj; Object matrixObj, bboxObj;
double m[6], bbox[4]; double m[6], bbox[4];
Object resObj; Object resObj;
Dict *resDict; Dict *resDict;
skipping to change at line 4829 skipping to change at line 4872
int c1, c2, c3; int c1, c2, c3;
// NB: this function is run even if ocState is false -- doImage() is // NB: this function is run even if ocState is false -- doImage() is
// responsible for skipping over the inline image data // responsible for skipping over the inline image data
// build dict/stream // build dict/stream
str = buildImageStream(&haveLength); str = buildImageStream(&haveLength);
// display the image // display the image
if (str) { if (str) {
doImage(NULL, str, gTrue); if (!doImage(NULL, str, gTrue)) {
delete str;
// if we have the stream length, skip to end-of-stream and then // if we have the stream length, skip to end-of-stream and then
// skip 'EI' in the original stream // skip 'EI' in the original stream
if (haveLength) { } else if (haveLength) {
while ((c1 = str->getChar()) != EOF) ; while ((c1 = str->getChar()) != EOF) ;
delete str; delete str;
str = parser->getStream(); str = parser->getStream();
c1 = str->getChar(); c1 = str->getChar();
c2 = str->getChar(); c2 = str->getChar();
c3 = str->lookChar(); c3 = str->lookChar();
while (!(c1 == 'E' && c2 == 'I' && Lexer::isSpace(c3)) && c3 != EOF) { while (!(c1 == 'E' && c2 == 'I' && Lexer::isSpace(c3)) && c3 != EOF) {
c1 = c2; c1 = c2;
c2 = str->getChar(); c2 = str->getChar();
c3 = str->lookChar(); c3 = str->lookChar();
skipping to change at line 4938 skipping to change at line 4982
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// type 3 font operators // type 3 font operators
//------------------------------------------------------------------------ //------------------------------------------------------------------------
void Gfx::opSetCharWidth(Object args[], int numArgs) { void Gfx::opSetCharWidth(Object args[], int numArgs) {
out->type3D0(state, args[0].getNum(), args[1].getNum()); out->type3D0(state, args[0].getNum(), args[1].getNum());
} }
void Gfx::opSetCacheDevice(Object args[], int numArgs) { void Gfx::opSetCacheDevice(Object args[], int numArgs) {
state->setInCachedT3Char(gTrue); state->setIgnoreColorOps(gTrue);
out->type3D1(state, args[0].getNum(), args[1].getNum(), out->type3D1(state, args[0].getNum(), args[1].getNum(),
args[2].getNum(), args[3].getNum(), args[2].getNum(), args[3].getNum(),
args[4].getNum(), args[5].getNum()); args[4].getNum(), args[5].getNum());
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// compatibility operators // compatibility operators
//------------------------------------------------------------------------ //------------------------------------------------------------------------
void Gfx::opBeginIgnoreUndef(Object args[], int numArgs) { void Gfx::opBeginIgnoreUndef(Object args[], int numArgs) {
 End of changes. 43 change blocks. 
70 lines changed or deleted 114 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)