+ return drawchar(obj, obj->swffont, character, charnr, u, &m);
+}
+
+static void endpage(struct swfoutput*obj)
+{
+ if(shapeid>=0)
+ endshape(obj,0);
+ if(textid>=0)
+ endtext(obj);
+ while(clippos)
+ swfoutput_endclip(obj);
+
+ if(insertstoptag) {
+ ActionTAG*atag=0;
+ atag = action_Stop(atag);
+ atag = action_End(atag);
+ tag = swf_InsertTag(tag,ST_DOACTION);
+ swf_ActionSet(tag,atag);
+ }
+ tag = swf_InsertTag(tag,ST_SHOWFRAME);
+}
+
+static int firstpage = 1;
+void swfoutput_newpage(struct swfoutput*obj, int pageNum, int x1, int y1, int x2, int y2)
+{
+ if(!firstpage)
+ endpage(obj);
+
+ for(depth--;depth>=startdepth;depth--) {
+ tag = swf_InsertTag(tag,ST_REMOVEOBJECT2);
+ swf_SetU16(tag,depth);
+ }
+ depth = startdepth = 3; /* leave room for clip and background rectangle */
+
+ sizex = x2;
+ sizey = y2;
+ x1*=20;y1*=20;x2*=20;y2*=20;
+
+ if(lastpagesize.xmin != x1 ||
+ lastpagesize.xmax != x2 ||
+ lastpagesize.ymin != y1 ||
+ lastpagesize.ymax != y2)
+ {/* add white clipping rectangle */
+ msg("<notice> processing page %d (%dx%d)", pageNum,sizex,sizey);
+
+ if(!firstpage) {
+ msg("<notice> Page has a different size than previous ones");
+ tag = swf_InsertTag(tag,ST_REMOVEOBJECT2);
+ swf_SetU16(tag,1);
+ tag = swf_InsertTag(tag,ST_REMOVEOBJECT2);
+ swf_SetU16(tag,2);
+ }
+
+ RGBA rgb;
+ rgb.a = rgb.r = rgb.g = rgb.b = 0xff;
+ SRECT r;
+ SHAPE* s;
+ int ls1=0,fs1=0;
+ int shapeid = ++currentswfid;
+ r.xmin = x1;
+ r.ymin = y1;
+ r.xmax = x2;
+ r.ymax = y2;
+ tag = swf_InsertTag(tag, ST_DEFINESHAPE);
+ swf_ShapeNew(&s);
+ fs1 = swf_ShapeAddSolidFillStyle(s, &rgb);
+ swf_SetU16(tag,shapeid);
+ swf_SetRect(tag,&r);
+ swf_SetShapeHeader(tag,s);
+ swf_ShapeSetAll(tag,s,x1,y1,ls1,fs1,0);
+ swf_ShapeSetLine(tag,s,(x2-x1),0);
+ swf_ShapeSetLine(tag,s,0,(y2-y1));
+ swf_ShapeSetLine(tag,s,(x1-x2),0);
+ swf_ShapeSetLine(tag,s,0,(y1-y2));
+ swf_ShapeSetEnd(tag);
+ swf_ShapeFree(s);
+ tag = swf_InsertTag(tag, ST_PLACEOBJECT2);
+ swf_ObjectPlace(tag,shapeid,/*depth*/1,0,0,0);
+ tag = swf_InsertTag(tag, ST_PLACEOBJECT2);
+ swf_ObjectPlaceClip(tag,shapeid,/*depth*/2,0,0,0,65535);
+ } else {
+ msg("<notice> processing page %d", pageNum);
+ }
+
+ lastpagesize.xmin = x1;
+ lastpagesize.xmax = x2;
+ lastpagesize.ymin = y1;
+ lastpagesize.ymax = y2;
+ swf_ExpandRect2(&swf.movieSize, &lastpagesize);
+
+ firstpage = 0;