X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=pdf2swf%2Fswfoutput.cc;h=8a129bc719e8cd815f108e23c13170c006d43e81;hb=5dda9633d8fdd97e0ed31fd88797984bf0642322;hp=27fdced65a3f5b43740d259f344cf7e4864a538c;hpb=bcc24611dd8738826b495e48ce2fdc8ce9c0b3e2;p=swftools.git diff --git a/pdf2swf/swfoutput.cc b/pdf2swf/swfoutput.cc index 27fdced..8a129bc 100644 --- a/pdf2swf/swfoutput.cc +++ b/pdf2swf/swfoutput.cc @@ -37,6 +37,7 @@ int jpegquality=85; int storeallcharacters=0; int enablezlib=0; int insertstoptag=0; +int flashversion=4; static int flag_protected = 0; typedef unsigned char u8; @@ -91,16 +92,18 @@ static void transform (plotxy*p0,struct swfmatrix*m) } // write a move-to command into the swf -static void moveto(TAG*tag, plotxy p0) +static int moveto(TAG*tag, plotxy p0) { int rx = (int)(p0.x*20); int ry = (int)(p0.y*20); if(rx!=swflastx || ry!=swflasty || fillstylechanged) { swf_ShapeSetMove (tag, shape, rx,ry); fillstylechanged = 0; + swflastx=rx; + swflasty=ry; + return 1; } - swflastx=rx; - swflasty=ry; + return 0; } // write a line-to command into the swf @@ -145,17 +148,29 @@ static void line(TAG*tag, plotxy p0, plotxy p1, struct swfmatrix*m) static void spline(TAG*tag,plotxy p0,plotxy p1,plotxy p2,plotxy p3,struct swfmatrix*m) { double d; - struct qspline q[16]; + struct qspline q[128]; int num; int t; transform(&p0,m); transform(&p1,m); transform(&p2,m); transform(&p3,m); - - num = approximate(p0,p1,p2,p3,q); + cspline c; + c.start = p3; + c.control1 = p2; + c.control2 = p1; + c.end = p0; + + if(storefont) { + /* fonts use a different approximation than shapes */ + num = cspline_approximate(&c, q, 10.0, APPROXIMATE_RECURSIVE_BINARY); + //num = cspline_approximate(&c, q, 10.0, APPROXIMATE_INFLECTION); + } else { + num = cspline_approximate(&c, q, 1.0, APPROXIMATE_RECURSIVE_BINARY); + } for(t=0;t=0) endshape(); @@ -1193,29 +1217,56 @@ void swfoutput_linktopage(struct swfoutput*obj, int page, swfcoord*points) drawlink(obj, actions, 0, points,0); } + +/* Named Links (a.k.a. Acrobatmenu) are used to implement various gadgets + of the viewer objects, like subtitles, index elements etc. +*/ void swfoutput_namedlink(struct swfoutput*obj, char*name, swfcoord*points) { ActionTAG *actions1,*actions2; + char*tmp = strdup(name); + char mouseover = 1; if(shapeid>=0) endshape(); if(textid>=0) endtext(); - - actions1 = action_PushString(0, "/:subtitle"); - actions1 = action_PushString(actions1, name); - actions1 = action_SetVariable(actions1); - actions1 = action_End(actions1); - actions2 = action_PushString(0, "/:subtitle"); - actions2 = action_PushString(actions2, ""); - actions2 = action_SetVariable(actions2); - actions2 = action_End(actions2); + if(!strncmp(tmp, "call:", 5)) + { + char*x = strchr(&tmp[5], ':'); + if(!x) { + actions1 = action_PushInt(0, 0); //number of parameters (0) + actions1 = action_PushString(actions1, &tmp[5]); //function name + actions1 = action_CallFunction(actions1); + } else { + *x = 0; + actions1 = action_PushString(0, x+1); //parameter + actions1 = action_PushInt(actions1, 1); //number of parameters (1) + actions1 = action_PushString(actions1, &tmp[5]); //function name + actions1 = action_CallFunction(actions1); + } + actions2 = action_End(0); + mouseover = 0; + } + else + { + actions1 = action_PushString(0, "/:subtitle"); + actions1 = action_PushString(actions1, name); + actions1 = action_SetVariable(actions1); + actions1 = action_End(actions1); + + actions2 = action_PushString(0, "/:subtitle"); + actions2 = action_PushString(actions2, ""); + actions2 = action_SetVariable(actions2); + actions2 = action_End(actions2); + } - drawlink(obj, actions1, actions2, points,1); + drawlink(obj, actions1, actions2, points,mouseover); swf_ActionFree(actions1); swf_ActionFree(actions2); + free(tmp); } static void drawlink(struct swfoutput*obj, ActionTAG*actions1, ActionTAG*actions2, swfcoord*points, char mouseover)