From fb28b953a31d3b3fc0d38e6b5d884ab6f8244918 Mon Sep 17 00:00:00 2001 From: kramm Date: Wed, 21 Nov 2001 15:50:33 +0000 Subject: [PATCH] fixed clipping bug: More than one clipping region inside a saved state wasn't handled correctly --- pdf2swf/SWFOutputDev.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pdf2swf/SWFOutputDev.cc b/pdf2swf/SWFOutputDev.cc index 532aa9a..e32a293 100644 --- a/pdf2swf/SWFOutputDev.cc +++ b/pdf2swf/SWFOutputDev.cc @@ -186,7 +186,7 @@ public: void drawGeneralImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap*colorMap, GBool invert, GBool inlineImg, int mask); - int clipping[32]; + int clipping[64]; int clippos; int setT1Font(char*name,FontEncoding*enc); @@ -507,7 +507,7 @@ void SWFOutputDev::clip(GfxState *state) m.m13 = 0; m.m23 = 0; T1_OUTLINE*outline = gfxPath_to_T1_OUTLINE(state, path); swfoutput_startclip(&output, outline, &m); - clipping[clippos] = 1; + clipping[clippos] ++; } void SWFOutputDev::eoClip(GfxState *state) { @@ -518,7 +518,7 @@ void SWFOutputDev::eoClip(GfxState *state) m.m12 = 0; m.m13 = 0; m.m23 = 0; T1_OUTLINE*outline = gfxPath_to_T1_OUTLINE(state, path); swfoutput_startclip(&output, outline, &m); - clipping[clippos] = 1; + clipping[clippos] ++; } SWFOutputDev::~SWFOutputDev() @@ -735,15 +735,20 @@ void SWFOutputDev::drawLink(Link *link, Catalog *catalog) void SWFOutputDev::saveState(GfxState *state) { logf(" saveState\n"); updateAll(state); - clippos ++; + if(clippos<64) + clippos ++; + else + logf(" Too many nested states in pdf."); clipping[clippos] = 0; }; void SWFOutputDev::restoreState(GfxState *state) { logf(" restoreState\n"); updateAll(state); - if(clipping[clippos]) + while(clipping[clippos]) { swfoutput_endclip(&output); + clipping[clippos]--; + } clippos--; } -- 1.7.10.4