diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc index 90bf41e..97f9245 100644 --- a/poppler/Gfx.cc +++ b/poppler/Gfx.cc @@ -468,7 +468,7 @@ GfxPattern *GfxResources::lookupPattern(char *name, OutputDev *out, GfxState *st for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->patternDict.isDict()) { if (!resPtr->patternDict.dictLookup(name, &obj)->isNull()) { - pattern = GfxPattern::parse(&obj, out, state); + pattern = GfxPattern::parse(resPtr, &obj, out, state); obj.free(); return pattern; } @@ -487,7 +487,7 @@ GfxShading *GfxResources::lookupShading(char *name, OutputDev *out, GfxState *st for (resPtr = this; resPtr; resPtr = resPtr->next) { if (resPtr->shadingDict.isDict()) { if (!resPtr->shadingDict.dictLookup(name, &obj)->isNull()) { - shading = GfxShading::parse(&obj, out, state); + shading = GfxShading::parse(resPtr, &obj, out, state); obj.free(); return shading; } @@ -1233,7 +1233,7 @@ void Gfx::opSetExtGState(Object args[], int numArgs) { blendingColorSpace = NULL; isolated = knockout = gFalse; if (!obj4.dictLookup("CS", &obj5)->isNull()) { - blendingColorSpace = GfxColorSpace::parse(&obj5, out, state); + blendingColorSpace = GfxColorSpace::parse(res, &obj5, out, state); } obj5.free(); if (obj4.dictLookup("I", &obj5)->isBool()) { @@ -1436,7 +1436,7 @@ void Gfx::opSetFillGray(Object args[], int numArgs) { state->setFillPattern(NULL); res->lookupColorSpace("DefaultGray", &obj); if (!obj.isNull()) { - colorSpace = GfxColorSpace::parse(&obj, out, state); + colorSpace = GfxColorSpace::parse(res, &obj, out, state); } if (colorSpace == NULL) { colorSpace = new GfxDeviceGrayColorSpace(); @@ -1457,7 +1457,7 @@ void Gfx::opSetStrokeGray(Object args[], int numArgs) { state->setStrokePattern(NULL); res->lookupColorSpace("DefaultGray", &obj); if (!obj.isNull()) { - colorSpace = GfxColorSpace::parse(&obj, out, state); + colorSpace = GfxColorSpace::parse(res, &obj, out, state); } if (colorSpace == NULL) { colorSpace = new GfxDeviceGrayColorSpace(); @@ -1478,7 +1478,7 @@ void Gfx::opSetFillCMYKColor(Object args[], int numArgs) { res->lookupColorSpace("DefaultCMYK", &obj); if (!obj.isNull()) { - colorSpace = GfxColorSpace::parse(&obj, out, state); + colorSpace = GfxColorSpace::parse(res, &obj, out, state); } if (colorSpace == NULL) { colorSpace = new GfxDeviceCMYKColorSpace(); @@ -1503,7 +1503,7 @@ void Gfx::opSetStrokeCMYKColor(Object args[], int numArgs) { state->setStrokePattern(NULL); res->lookupColorSpace("DefaultCMYK", &obj); if (!obj.isNull()) { - colorSpace = GfxColorSpace::parse(&obj, out, state); + colorSpace = GfxColorSpace::parse(res, &obj, out, state); } if (colorSpace == NULL) { colorSpace = new GfxDeviceCMYKColorSpace(); @@ -1527,7 +1527,7 @@ void Gfx::opSetFillRGBColor(Object args[], int numArgs) { state->setFillPattern(NULL); res->lookupColorSpace("DefaultRGB", &obj); if (!obj.isNull()) { - colorSpace = GfxColorSpace::parse(&obj, out, state); + colorSpace = GfxColorSpace::parse(res, &obj, out, state); } if (colorSpace == NULL) { colorSpace = new GfxDeviceRGBColorSpace(); @@ -1551,7 +1551,7 @@ void Gfx::opSetStrokeRGBColor(Object args[], int numArgs) { state->setStrokePattern(NULL); res->lookupColorSpace("DefaultRGB", &obj); if (!obj.isNull()) { - colorSpace = GfxColorSpace::parse(&obj, out, state); + colorSpace = GfxColorSpace::parse(res, &obj, out, state); } if (colorSpace == NULL) { colorSpace = new GfxDeviceRGBColorSpace(); @@ -1573,9 +1573,9 @@ void Gfx::opSetFillColorSpace(Object args[], int numArgs) { res->lookupColorSpace(args[0].getName(), &obj); if (obj.isNull()) { - colorSpace = GfxColorSpace::parse(&args[0], out, state); + colorSpace = GfxColorSpace::parse(res, &args[0], out, state); } else { - colorSpace = GfxColorSpace::parse(&obj, out, state); + colorSpace = GfxColorSpace::parse(res, &obj, out, state); } obj.free(); if (colorSpace) { @@ -1598,9 +1598,9 @@ void Gfx::opSetStrokeColorSpace(Object args[], int numArgs) { state->setStrokePattern(NULL); res->lookupColorSpace(args[0].getName(), &obj); if (obj.isNull()) { - colorSpace = GfxColorSpace::parse(&args[0], out, state); + colorSpace = GfxColorSpace::parse(res, &args[0], out, state); } else { - colorSpace = GfxColorSpace::parse(&obj, out, state); + colorSpace = GfxColorSpace::parse(res, &obj, out, state); } obj.free(); if (colorSpace) { @@ -4400,7 +4400,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { } state->setRenderingIntent(objIntent.getName()); } - colorSpace = GfxColorSpace::parse(&obj1, out, state); + colorSpace = GfxColorSpace::parse(res, &obj1, out, state); if (objIntent.isName()) { state->setRenderingIntent(tempIntent); free(tempIntent); @@ -4412,7 +4412,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { if (objCS.isNull()) { colorSpace = new GfxDeviceGrayColorSpace(); } else { - colorSpace = GfxColorSpace::parse(&objCS, out, state); + colorSpace = GfxColorSpace::parse(res, &objCS, out, state); } objCS.free(); } else if (csMode == streamCSDeviceRGB) { @@ -4421,7 +4421,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { if (objCS.isNull()) { colorSpace = new GfxDeviceRGBColorSpace(); } else { - colorSpace = GfxColorSpace::parse(&objCS, out, state); + colorSpace = GfxColorSpace::parse(res, &objCS, out, state); } objCS.free(); } else if (csMode == streamCSDeviceCMYK) { @@ -4430,7 +4430,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { if (objCS.isNull()) { colorSpace = new GfxDeviceCMYKColorSpace(); } else { - colorSpace = GfxColorSpace::parse(&objCS, out, state); + colorSpace = GfxColorSpace::parse(res, &objCS, out, state); } objCS.free(); } else { @@ -4525,7 +4525,7 @@ void Gfx::doImage(Object *ref, Stream *str, GBool inlineImg) { obj2.free(); } } - maskColorSpace = GfxColorSpace::parse(&obj1, out, state); + maskColorSpace = GfxColorSpace::parse(res, &obj1, out, state); obj1.free(); if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) { goto err1; @@ -4821,7 +4821,7 @@ void Gfx::doForm(Object *str) { if (dict->lookup("Group", &obj1)->isDict()) { if (obj1.dictLookup("S", &obj2)->isName("Transparency")) { if (!obj1.dictLookup("CS", &obj3)->isNull()) { - blendingColorSpace = GfxColorSpace::parse(&obj3, out, state); + blendingColorSpace = GfxColorSpace::parse(res, &obj3, out, state); } obj3.free(); if (obj1.dictLookup("I", &obj3)->isBool()) { diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc index eb11777..310235d 100644 --- a/poppler/GfxState.cc +++ b/poppler/GfxState.cc @@ -282,7 +282,7 @@ GfxColorSpace::GfxColorSpace() { GfxColorSpace::~GfxColorSpace() { } -GfxColorSpace *GfxColorSpace::parse(Object *csObj, OutputDev *out, GfxState *state, int recursion) { +GfxColorSpace *GfxColorSpace::parse(GfxResources *res, Object *csObj, OutputDev *out, GfxState *state, int recursion) { GfxColorSpace *cs; Object obj1; @@ -294,11 +294,44 @@ GfxColorSpace *GfxColorSpace::parse(Object *csObj, OutputDev *out, GfxState *sta cs = NULL; if (csObj->isName()) { if (csObj->isName("DeviceGray") || csObj->isName("G")) { - cs = new GfxDeviceGrayColorSpace(); + if (res != NULL) { + Object objCS; + res->lookupColorSpace("DefaultGray", &objCS); + if (objCS.isNull()) { + cs = new GfxDeviceGrayColorSpace(); + } else { + cs = GfxColorSpace::parse(res, &objCS, out, state); + } + objCS.free(); + } else { + cs = new GfxDeviceGrayColorSpace(); + } } else if (csObj->isName("DeviceRGB") || csObj->isName("RGB")) { - cs = new GfxDeviceRGBColorSpace(); + if (res != NULL) { + Object objCS; + res->lookupColorSpace("DefaultRGB", &objCS); + if (objCS.isNull()) { + cs = new GfxDeviceRGBColorSpace(); + } else { + cs = GfxColorSpace::parse(res, &objCS, out, state); + } + objCS.free(); + } else { + cs = new GfxDeviceRGBColorSpace(); + } } else if (csObj->isName("DeviceCMYK") || csObj->isName("CMYK")) { - cs = new GfxDeviceCMYKColorSpace(); + if (res != NULL) { + Object objCS; + res->lookupColorSpace("DefaultCMYK", &objCS); + if (objCS.isNull()) { + cs = new GfxDeviceCMYKColorSpace(); + } else { + cs = GfxColorSpace::parse(res, &objCS, out, state); + } + objCS.free(); + } else { + cs = new GfxDeviceCMYKColorSpace(); + } } else if (csObj->isName("Pattern")) { cs = new GfxPatternColorSpace(NULL); } else { @@ -307,11 +340,44 @@ GfxColorSpace *GfxColorSpace::parse(Object *csObj, OutputDev *out, GfxState *sta } else if (csObj->isArray() && csObj->arrayGetLength() > 0) { csObj->arrayGet(0, &obj1); if (obj1.isName("DeviceGray") || obj1.isName("G")) { - cs = new GfxDeviceGrayColorSpace(); + if (res != NULL) { + Object objCS; + res->lookupColorSpace("DefaultGray", &objCS); + if (objCS.isNull()) { + cs = new GfxDeviceGrayColorSpace(); + } else { + cs = GfxColorSpace::parse(res, &objCS, out, state); + } + objCS.free(); + } else { + cs = new GfxDeviceGrayColorSpace(); + } } else if (obj1.isName("DeviceRGB") || obj1.isName("RGB")) { - cs = new GfxDeviceRGBColorSpace(); + if (res != NULL) { + Object objCS; + res->lookupColorSpace("DefaultRGB", &objCS); + if (objCS.isNull()) { + cs = new GfxDeviceRGBColorSpace(); + } else { + cs = GfxColorSpace::parse(res, &objCS, out, state); + } + objCS.free(); + } else { + cs = new GfxDeviceRGBColorSpace(); + } } else if (obj1.isName("DeviceCMYK") || obj1.isName("CMYK")) { - cs = new GfxDeviceCMYKColorSpace(); + if (res != NULL) { + Object objCS; + res->lookupColorSpace("DefaultCMYK", &objCS); + if (objCS.isNull()) { + cs = new GfxDeviceCMYKColorSpace(); + } else { + cs = GfxColorSpace::parse(res, &objCS, out, state); + } + objCS.free(); + } else { + cs = new GfxDeviceCMYKColorSpace(); + } } else if (obj1.isName("CalGray")) { cs = GfxCalGrayColorSpace::parse(csObj->getArray(), state); } else if (obj1.isName("CalRGB")) { @@ -321,13 +387,13 @@ GfxColorSpace *GfxColorSpace::parse(Object *csObj, OutputDev *out, GfxState *sta } else if (obj1.isName("ICCBased")) { cs = GfxICCBasedColorSpace::parse(csObj->getArray(), out, state, recursion); } else if (obj1.isName("Indexed") || obj1.isName("I")) { - cs = GfxIndexedColorSpace::parse(csObj->getArray(), out, state, recursion); + cs = GfxIndexedColorSpace::parse(res, csObj->getArray(), out, state, recursion); } else if (obj1.isName("Separation")) { - cs = GfxSeparationColorSpace::parse(csObj->getArray(), out, state, recursion); + cs = GfxSeparationColorSpace::parse(res, csObj->getArray(), out, state, recursion); } else if (obj1.isName("DeviceN")) { - cs = GfxDeviceNColorSpace::parse(csObj->getArray(), out, state, recursion); + cs = GfxDeviceNColorSpace::parse(res, csObj->getArray(), out, state, recursion); } else if (obj1.isName("Pattern")) { - cs = GfxPatternColorSpace::parse(csObj->getArray(), out, state, recursion); + cs = GfxPatternColorSpace::parse(res, csObj->getArray(), out, state, recursion); } else { error(errSyntaxWarning, -1, "Bad color space"); } @@ -335,11 +401,44 @@ GfxColorSpace *GfxColorSpace::parse(Object *csObj, OutputDev *out, GfxState *sta } else if (csObj->isDict()) { csObj->dictLookup("ColorSpace", &obj1); if (obj1.isName("DeviceGray")) { - cs = new GfxDeviceGrayColorSpace(); + if (res != NULL) { + Object objCS; + res->lookupColorSpace("DefaultGray", &objCS); + if (objCS.isNull()) { + cs = new GfxDeviceGrayColorSpace(); + } else { + cs = GfxColorSpace::parse(res, &objCS, out, state); + } + objCS.free(); + } else { + cs = new GfxDeviceGrayColorSpace(); + } } else if (obj1.isName("DeviceRGB")) { - cs = new GfxDeviceRGBColorSpace(); + if (res != NULL) { + Object objCS; + res->lookupColorSpace("DefaultRGB", &objCS); + if (objCS.isNull()) { + cs = new GfxDeviceRGBColorSpace(); + } else { + cs = GfxColorSpace::parse(res, &objCS, out, state); + } + objCS.free(); + } else { + cs = new GfxDeviceRGBColorSpace(); + } } else if (obj1.isName("DeviceCMYK")) { - cs = new GfxDeviceCMYKColorSpace(); + if (res != NULL) { + Object objCS; + res->lookupColorSpace("DefaultCMYK", &objCS); + if (objCS.isNull()) { + cs = new GfxDeviceCMYKColorSpace(); + } else { + cs = GfxColorSpace::parse(res, &objCS, out, state); + } + objCS.free(); + } else { + cs = new GfxDeviceCMYKColorSpace(); + } } else { error(errSyntaxWarning, -1, "Bad color space dict'"); } @@ -1871,7 +1970,7 @@ GfxColorSpace *GfxICCBasedColorSpace::parse(Array *arr, OutputDev *out, GfxState nCompsA = 4; } if (dict->lookup("Alternate", &obj2)->isNull() || - !(altA = GfxColorSpace::parse(&obj2, out, state, recursion + 1))) { + !(altA = GfxColorSpace::parse(NULL, &obj2, out, state, recursion + 1))) { switch (nCompsA) { case 1: altA = new GfxDeviceGrayColorSpace(); @@ -2420,7 +2519,7 @@ GfxColorSpace *GfxIndexedColorSpace::copy() { return cs; } -GfxColorSpace *GfxIndexedColorSpace::parse(Array *arr, OutputDev *out, GfxState *state, int recursion) { +GfxColorSpace *GfxIndexedColorSpace::parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion) { GfxIndexedColorSpace *cs; GfxColorSpace *baseA; int indexHighA; @@ -2433,7 +2532,7 @@ GfxColorSpace *GfxIndexedColorSpace::parse(Array *arr, OutputDev *out, GfxState goto err1; } arr->get(1, &obj1); - if (!(baseA = GfxColorSpace::parse(&obj1, out, state, recursion + 1))) { + if (!(baseA = GfxColorSpace::parse(res, &obj1, out, state, recursion + 1))) { error(errSyntaxWarning, -1, "Bad Indexed color space (base color space)"); goto err2; } @@ -2685,7 +2784,7 @@ GfxColorSpace *GfxSeparationColorSpace::copy() { } //~ handle the 'All' and 'None' colorants -GfxColorSpace *GfxSeparationColorSpace::parse(Array *arr, OutputDev *out, GfxState *state, int recursion) { +GfxColorSpace *GfxSeparationColorSpace::parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion) { GfxSeparationColorSpace *cs; GooString *nameA; GfxColorSpace *altA; @@ -2703,7 +2802,7 @@ GfxColorSpace *GfxSeparationColorSpace::parse(Array *arr, OutputDev *out, GfxSta nameA = new GooString(obj1.getName()); obj1.free(); arr->get(2, &obj1); - if (!(altA = GfxColorSpace::parse(&obj1, out, state, recursion + 1))) { + if (!(altA = GfxColorSpace::parse(res, &obj1, out, state, recursion + 1))) { error(errSyntaxWarning, -1, "Bad Separation color space (alternate color space)"); goto err3; } @@ -2934,7 +3033,7 @@ GfxColorSpace *GfxDeviceNColorSpace::copy() { } //~ handle the 'None' colorant -GfxColorSpace *GfxDeviceNColorSpace::parse(Array *arr, OutputDev *out, GfxState *state, int recursion) { +GfxColorSpace *GfxDeviceNColorSpace::parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion) { GfxDeviceNColorSpace *cs; int nCompsA; GooString *namesA[gfxColorMaxComps]; @@ -2969,7 +3068,7 @@ GfxColorSpace *GfxDeviceNColorSpace::parse(Array *arr, OutputDev *out, GfxState } obj1.free(); arr->get(2, &obj1); - if (!(altA = GfxColorSpace::parse(&obj1, out, state, recursion + 1))) { + if (!(altA = GfxColorSpace::parse(res, &obj1, out, state, recursion + 1))) { error(errSyntaxWarning, -1, "Bad DeviceN color space (alternate color space)"); goto err3; } @@ -2992,7 +3091,7 @@ GfxColorSpace *GfxDeviceNColorSpace::parse(Array *arr, OutputDev *out, GfxState Object obj3; colorants->getVal(i, &obj3); if (obj3.isArray()) { - separationList->append(GfxSeparationColorSpace::parse(obj3.getArray(), out, state, recursion)); + separationList->append(GfxSeparationColorSpace::parse(res, obj3.getArray(), out, state, recursion)); } else { obj3.free(); obj2.free(); @@ -3200,7 +3299,7 @@ GfxColorSpace *GfxPatternColorSpace::copy() { (GfxColorSpace *)NULL); } -GfxColorSpace *GfxPatternColorSpace::parse(Array *arr, OutputDev *out, GfxState *state, int recursion) { +GfxColorSpace *GfxPatternColorSpace::parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion) { GfxPatternColorSpace *cs; GfxColorSpace *underA; Object obj1; @@ -3212,7 +3311,7 @@ GfxColorSpace *GfxPatternColorSpace::parse(Array *arr, OutputDev *out, GfxState underA = NULL; if (arr->getLength() == 2) { arr->get(1, &obj1); - if (!(underA = GfxColorSpace::parse(&obj1, out, state, recursion + 1))) { + if (!(underA = GfxColorSpace::parse(res, &obj1, out, state, recursion + 1))) { error(errSyntaxWarning, -1, "Bad Pattern color space (underlying color space)"); obj1.free(); return NULL; @@ -3257,7 +3356,7 @@ GfxPattern::GfxPattern(int typeA) { GfxPattern::~GfxPattern() { } -GfxPattern *GfxPattern::parse(Object *obj, OutputDev *out, GfxState *state) { +GfxPattern *GfxPattern::parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state) { GfxPattern *pattern; Object obj1; @@ -3272,7 +3371,7 @@ GfxPattern *GfxPattern::parse(Object *obj, OutputDev *out, GfxState *state) { if (obj1.isInt() && obj1.getInt() == 1) { pattern = GfxTilingPattern::parse(obj); } else if (obj1.isInt() && obj1.getInt() == 2) { - pattern = GfxShadingPattern::parse(obj, out, state); + pattern = GfxShadingPattern::parse(res, obj, out, state); } obj1.free(); return pattern; @@ -3400,7 +3499,7 @@ GfxPattern *GfxTilingPattern::copy() { // GfxShadingPattern //------------------------------------------------------------------------ -GfxShadingPattern *GfxShadingPattern::parse(Object *patObj, OutputDev *out, GfxState *state) { +GfxShadingPattern *GfxShadingPattern::parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state) { Dict *dict; GfxShading *shadingA; double matrixA[6]; @@ -3413,7 +3512,7 @@ GfxShadingPattern *GfxShadingPattern::parse(Object *patObj, OutputDev *out, GfxS dict = patObj->getDict(); dict->lookup("Shading", &obj1); - shadingA = GfxShading::parse(&obj1, out, state); + shadingA = GfxShading::parse(res, &obj1, out, state); obj1.free(); if (!shadingA) { return NULL; @@ -3486,7 +3585,7 @@ GfxShading::~GfxShading() { } } -GfxShading *GfxShading::parse(Object *obj, OutputDev *out, GfxState *state) { +GfxShading *GfxShading::parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state) { GfxShading *shading; Dict *dict; int typeA; @@ -3510,17 +3609,17 @@ GfxShading *GfxShading::parse(Object *obj, OutputDev *out, GfxState *state) { switch (typeA) { case 1: - shading = GfxFunctionShading::parse(dict, out, state); + shading = GfxFunctionShading::parse(res, dict, out, state); break; case 2: - shading = GfxAxialShading::parse(dict, out, state); + shading = GfxAxialShading::parse(res, dict, out, state); break; case 3: - shading = GfxRadialShading::parse(dict, out, state); + shading = GfxRadialShading::parse(res, dict, out, state); break; case 4: if (obj->isStream()) { - shading = GfxGouraudTriangleShading::parse(4, dict, obj->getStream(), out, state); + shading = GfxGouraudTriangleShading::parse(res, 4, dict, obj->getStream(), out, state); } else { error(errSyntaxWarning, -1, "Invalid Type 4 shading object"); goto err1; @@ -3528,7 +3627,7 @@ GfxShading *GfxShading::parse(Object *obj, OutputDev *out, GfxState *state) { break; case 5: if (obj->isStream()) { - shading = GfxGouraudTriangleShading::parse(5, dict, obj->getStream(), out, state); + shading = GfxGouraudTriangleShading::parse(res, 5, dict, obj->getStream(), out, state); } else { error(errSyntaxWarning, -1, "Invalid Type 5 shading object"); goto err1; @@ -3536,7 +3635,7 @@ GfxShading *GfxShading::parse(Object *obj, OutputDev *out, GfxState *state) { break; case 6: if (obj->isStream()) { - shading = GfxPatchMeshShading::parse(6, dict, obj->getStream(), out, state); + shading = GfxPatchMeshShading::parse(res, 6, dict, obj->getStream(), out, state); } else { error(errSyntaxWarning, -1, "Invalid Type 6 shading object"); goto err1; @@ -3544,7 +3643,7 @@ GfxShading *GfxShading::parse(Object *obj, OutputDev *out, GfxState *state) { break; case 7: if (obj->isStream()) { - shading = GfxPatchMeshShading::parse(7, dict, obj->getStream(), out, state); + shading = GfxPatchMeshShading::parse(res, 7, dict, obj->getStream(), out, state); } else { error(errSyntaxWarning, -1, "Invalid Type 7 shading object"); goto err1; @@ -3561,12 +3660,12 @@ GfxShading *GfxShading::parse(Object *obj, OutputDev *out, GfxState *state) { return NULL; } -GBool GfxShading::init(Dict *dict, OutputDev *out, GfxState *state) { +GBool GfxShading::init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) { Object obj1, obj2; int i; dict->lookup("ColorSpace", &obj1); - if (!(colorSpace = GfxColorSpace::parse(&obj1, out, state))) { + if (!(colorSpace = GfxColorSpace::parse(res, &obj1, out, state))) { error(errSyntaxWarning, -1, "Bad color space in shading dictionary"); obj1.free(); return gFalse; @@ -3673,7 +3772,7 @@ GfxFunctionShading::~GfxFunctionShading() { } } -GfxFunctionShading *GfxFunctionShading::parse(Dict *dict, OutputDev *out, GfxState *state) { +GfxFunctionShading *GfxFunctionShading::parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) { GfxFunctionShading *shading; double x0A, y0A, x1A, y1A; double matrixA[6]; @@ -3741,7 +3840,7 @@ GfxFunctionShading *GfxFunctionShading::parse(Dict *dict, OutputDev *out, GfxSta shading = new GfxFunctionShading(x0A, y0A, x1A, y1A, matrixA, funcsA, nFuncsA); - if (!shading->init(dict, out, state)) { + if (!shading->init(res, dict, out, state)) { delete shading; return NULL; } @@ -3992,7 +4091,7 @@ GfxAxialShading::GfxAxialShading(GfxAxialShading *shading): GfxAxialShading::~GfxAxialShading() { } -GfxAxialShading *GfxAxialShading::parse(Dict *dict, OutputDev *out, GfxState *state) { +GfxAxialShading *GfxAxialShading::parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) { GfxAxialShading *shading; double x0A, y0A, x1A, y1A; double t0A, t1A; @@ -4089,7 +4188,7 @@ GfxAxialShading *GfxAxialShading::parse(Dict *dict, OutputDev *out, GfxState *st shading = new GfxAxialShading(x0A, y0A, x1A, y1A, t0A, t1A, funcsA, nFuncsA, extend0A, extend1A); - if (!shading->init(dict, out, state)) { + if (!shading->init(res, dict, out, state)) { delete shading; return NULL; } @@ -4200,7 +4299,7 @@ GfxRadialShading::GfxRadialShading(GfxRadialShading *shading): GfxRadialShading::~GfxRadialShading() { } -GfxRadialShading *GfxRadialShading::parse(Dict *dict, OutputDev *out, GfxState *state) { +GfxRadialShading *GfxRadialShading::parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state) { GfxRadialShading *shading; double x0A, y0A, r0A, x1A, y1A, r1A; double t0A, t1A; @@ -4279,7 +4378,7 @@ GfxRadialShading *GfxRadialShading::parse(Dict *dict, OutputDev *out, GfxState * shading = new GfxRadialShading(x0A, y0A, r0A, x1A, y1A, r1A, t0A, t1A, funcsA, nFuncsA, extend0A, extend1A); - if (!shading->init(dict, out, state)) { + if (!shading->init(res, dict, out, state)) { delete shading; return NULL; } @@ -4720,7 +4819,7 @@ GfxGouraudTriangleShading::~GfxGouraudTriangleShading() { } } -GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse(int typeA, +GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse(GfxResources *res, int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *gfxState) { @@ -4919,7 +5018,7 @@ GfxGouraudTriangleShading *GfxGouraudTriangleShading::parse(int typeA, shading = new GfxGouraudTriangleShading(typeA, verticesA, nVerticesA, trianglesA, nTrianglesA, funcsA, nFuncsA); - if (!shading->init(dict, out, gfxState)) { + if (!shading->init(res, dict, out, gfxState)) { delete shading; return NULL; } @@ -5065,7 +5164,7 @@ GfxPatchMeshShading::~GfxPatchMeshShading() { } } -GfxPatchMeshShading *GfxPatchMeshShading::parse(int typeA, Dict *dict, +GfxPatchMeshShading *GfxPatchMeshShading::parse(GfxResources *res, int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state) { GfxPatchMeshShading *shading; Function *funcsA[gfxColorMaxComps]; @@ -5590,7 +5689,7 @@ GfxPatchMeshShading *GfxPatchMeshShading::parse(int typeA, Dict *dict, shading = new GfxPatchMeshShading(typeA, patchesA, nPatchesA, funcsA, nFuncsA); - if (!shading->init(dict, out, state)) { + if (!shading->init(res, dict, out, state)) { delete shading; return NULL; } diff --git a/poppler/GfxState.h b/poppler/GfxState.h index 106b2c0..3f195c2 100644 --- a/poppler/GfxState.h +++ b/poppler/GfxState.h @@ -53,6 +53,7 @@ class PopplerCache; class GooList; class OutputDev; class GfxState; +class GfxResources; class Matrix { public: @@ -205,7 +206,7 @@ public: virtual GfxColorSpaceMode getMode() = 0; // Construct a color space. Returns NULL if unsuccessful. - static GfxColorSpace *parse(Object *csObj, OutputDev *out, GfxState *state, int recursion = 0); + static GfxColorSpace *parse(GfxResources *res, Object *csObj, OutputDev *out, GfxState *state, int recursion = 0); // Convert to gray, RGB, or CMYK. virtual void getGray(GfxColor *color, GfxGray *gray) = 0; @@ -578,7 +579,7 @@ public: virtual GfxColorSpaceMode getMode() { return csIndexed; } // Construct an Indexed color space. Returns NULL if unsuccessful. - static GfxColorSpace *parse(Array *arr, OutputDev *out, GfxState *state, int recursion); + static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion); virtual void getGray(GfxColor *color, GfxGray *gray); virtual void getRGB(GfxColor *color, GfxRGB *rgb); @@ -631,7 +632,7 @@ public: virtual GfxColorSpaceMode getMode() { return csSeparation; } // Construct a Separation color space. Returns NULL if unsuccessful. - static GfxColorSpace *parse(Array *arr, OutputDev *out, GfxState *state, int recursion); + static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion); virtual void getGray(GfxColor *color, GfxGray *gray); virtual void getRGB(GfxColor *color, GfxRGB *rgb); @@ -676,7 +677,7 @@ public: virtual GfxColorSpaceMode getMode() { return csDeviceN; } // Construct a DeviceN color space. Returns NULL if unsuccessful. - static GfxColorSpace *parse(Array *arr, OutputDev *out, GfxState *state, int recursion); + static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion); virtual void getGray(GfxColor *color, GfxGray *gray); virtual void getRGB(GfxColor *color, GfxRGB *rgb); @@ -723,7 +724,7 @@ public: virtual GfxColorSpaceMode getMode() { return csPattern; } // Construct a Pattern color space. Returns NULL if unsuccessful. - static GfxColorSpace *parse(Array *arr, OutputDev *out, GfxState *state, int recursion); + static GfxColorSpace *parse(GfxResources *res, Array *arr, OutputDev *out, GfxState *state, int recursion); virtual void getGray(GfxColor *color, GfxGray *gray); virtual void getRGB(GfxColor *color, GfxRGB *rgb); @@ -752,7 +753,7 @@ public: GfxPattern(int typeA); virtual ~GfxPattern(); - static GfxPattern *parse(Object *obj, OutputDev *out, GfxState *state); + static GfxPattern *parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state); virtual GfxPattern *copy() = 0; @@ -808,7 +809,7 @@ private: class GfxShadingPattern: public GfxPattern { public: - static GfxShadingPattern *parse(Object *patObj, OutputDev *out, GfxState *state); + static GfxShadingPattern *parse(GfxResources *res, Object *patObj, OutputDev *out, GfxState *state); virtual ~GfxShadingPattern(); virtual GfxPattern *copy(); @@ -835,7 +836,7 @@ public: GfxShading(GfxShading *shading); virtual ~GfxShading(); - static GfxShading *parse(Object *obj, OutputDev *out, GfxState *state); + static GfxShading *parse(GfxResources *res, Object *obj, OutputDev *out, GfxState *state); virtual GfxShading *copy() = 0; @@ -849,7 +850,7 @@ public: protected: - GBool init(Dict *dict, OutputDev *out, GfxState *state); + GBool init(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state); int type; GfxColorSpace *colorSpace; @@ -918,7 +919,7 @@ public: GfxFunctionShading(GfxFunctionShading *shading); virtual ~GfxFunctionShading(); - static GfxFunctionShading *parse(Dict *dict, OutputDev *out, GfxState *state); + static GfxFunctionShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state); virtual GfxShading *copy(); @@ -952,7 +953,7 @@ public: GfxAxialShading(GfxAxialShading *shading); virtual ~GfxAxialShading(); - static GfxAxialShading *parse(Dict *dict, OutputDev *out, GfxState *state); + static GfxAxialShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state); virtual GfxShading *copy(); @@ -985,7 +986,7 @@ public: GfxRadialShading(GfxRadialShading *shading); virtual ~GfxRadialShading(); - static GfxRadialShading *parse(Dict *dict, OutputDev *out, GfxState *state); + static GfxRadialShading *parse(GfxResources *res, Dict *dict, OutputDev *out, GfxState *state); virtual GfxShading *copy(); @@ -1023,7 +1024,7 @@ public: GfxGouraudTriangleShading(GfxGouraudTriangleShading *shading); virtual ~GfxGouraudTriangleShading(); - static GfxGouraudTriangleShading *parse(int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state); + static GfxGouraudTriangleShading *parse(GfxResources *res, int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state); virtual GfxShading *copy(); @@ -1109,7 +1110,7 @@ public: GfxPatchMeshShading(GfxPatchMeshShading *shading); virtual ~GfxPatchMeshShading(); - static GfxPatchMeshShading *parse(int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state); + static GfxPatchMeshShading *parse(GfxResources *res, int typeA, Dict *dict, Stream *str, OutputDev *out, GfxState *state); virtual GfxShading *copy(); diff --git a/poppler/Page.cc b/poppler/Page.cc index ecdff32..6b419ac 100644 --- a/poppler/Page.cc +++ b/poppler/Page.cc @@ -672,7 +672,7 @@ GBool Page::loadThumb(unsigned char **data_out, obj1.free (); dict->lookup ("CS", &obj1); } - colorSpace = GfxColorSpace::parse(&obj1, NULL, NULL); + colorSpace = GfxColorSpace::parse(NULL, &obj1, NULL, NULL); obj1.free(); if (!colorSpace) { fprintf (stderr, "Error: Cannot parse color space\n");