From 1328e56e38a5148fb51eb0225c5570bc6d4645b4 Mon Sep 17 00:00:00 2001 From: kramm Date: Tue, 22 Apr 2008 09:30:00 +0000 Subject: [PATCH] made dash setting persistent --- lib/pdf/GFXOutputDev.cc | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/lib/pdf/GFXOutputDev.cc b/lib/pdf/GFXOutputDev.cc index 27042b8..88fa728 100644 --- a/lib/pdf/GFXOutputDev.cc +++ b/lib/pdf/GFXOutputDev.cc @@ -1026,6 +1026,10 @@ void GFXOutputDev::endPage() device->endclip(device); outer_clip_box = 0; } + if(this->dashPattern) { + free(this->dashPattern); + this->dashPattern = 0; + } /* notice: we're not fully done yet with this page- there might still be a few calls to drawLink() yet to come */ } @@ -1050,7 +1054,7 @@ void GFXOutputDev::strokeGfxline(GfxState *state, gfxline_t*line, int flags) col.g = colToByte(rgb.g); col.b = colToByte(rgb.b); col.a = (unsigned char)(opaq*255); - + gfx_capType capType = gfx_capRound; if(lineCap == 0) capType = gfx_capButt; else if(lineCap == 1) capType = gfx_capRound; @@ -1061,28 +1065,23 @@ void GFXOutputDev::strokeGfxline(GfxState *state, gfxline_t*line, int flags) else if(lineJoin == 1) joinType = gfx_joinRound; else if(lineJoin == 2) joinType = gfx_joinBevel; - int dashnum = 0; - double dashphase = 0; - double * ldash = 0; - state->getLineDash(&ldash, &dashnum, &dashphase); - gfxline_t*line2 = 0; - if(dashnum && ldash) { - float * dash = (float*)malloc(sizeof(float)*(dashnum+1)); + if(0 && this->dashLength && this->dashPattern) { + float * dash = (float*)malloc(sizeof(float)*(this->dashLength+1)); int t; - msg(" %d dashes", dashnum); - msg(" | phase: %f", dashphase); - for(t=0;t | d%-3d: %f", t, ldash[t]); + msg(" %d dashes", this->dashLength); + msg(" | phase: %f", this->dashStart); + for(t=0;tdashLength;t++) { + dash[t] = (float)this->dashPattern[t]; + msg(" | d%-3d: %f", t, this->dashPattern[t]); } - dash[dashnum] = -1; + dash[this->dashLength] = -1; if(getLogLevel() >= LOGLEVEL_TRACE) { dump_outline(line); } - line2 = gfxtool_dash_line(line, dash, (float)dashphase); + line2 = gfxtool_dash_line(line, dash, (float)this->dashStart); line = line2; free(dash); msg(" After dashing:"); @@ -1093,7 +1092,7 @@ void GFXOutputDev::strokeGfxline(GfxState *state, gfxline_t*line, int flags) width, lineJoin==0?"miter": (lineJoin==1?"round":"bevel"), lineCap==0?"butt": (lineJoin==1?"round":"square"), - dashnum, + this->dashLength, col.r,col.g,col.b,col.a ); dump_outline(line); @@ -1529,6 +1528,10 @@ void GFXOutputDev::startPage(int pageNum, GfxState *state, double crop_x1, doubl states[statepos].clipbbox.ymin = x1; states[statepos].clipbbox.xmax = x2; states[statepos].clipbbox.ymax = y2; + + this->dashPattern = 0; + this->dashLength = 0; + this->dashStart = 0; } @@ -1755,11 +1758,19 @@ void GFXOutputDev::restoreState(GfxState *state) { } statepos--; } + +void GFXOutputDev::updateLineDash(GfxState *state) +{ + state->getLineDash(&this->dashPattern, &this->dashLength, &this->dashStart); + msg(" updateLineDash, %d dashes", this->dashLength); + if(!this->dashLength) { + this->dashPattern = 0; + } +} void GFXOutputDev::updateLineWidth(GfxState *state) { double width = state->getTransformedLineWidth(); - //swfoutput_setlinewidth(&device, width); } void GFXOutputDev::updateLineCap(GfxState *state) -- 1.7.10.4