@@ -429,6 +429,16 @@ protected List<AffineTransform> applyTranform(RenderingContext c, Box box) {
429
429
RectPropertySet margin = c .getPage ().getMargin (c );
430
430
relTranslateX += margin .left ();
431
431
relTranslateY += margin .top ();
432
+
433
+ /*
434
+ * We must apply the top/bottom margins from the previous pages, otherwise
435
+ * our transform center is wrong.
436
+ */
437
+ for (int i = 0 ; i < c .getPageNo (); i ++) {
438
+ RectPropertySet prevMargin = getPages ().get (i ).getMargin (c );
439
+ relTranslateY += prevMargin .top () + prevMargin .bottom ();
440
+ }
441
+
432
442
433
443
MarginBoxName [] marginBoxNames = c .getPage ().getCurrentMarginBoxNames ();
434
444
if (marginBoxNames != null ) {
@@ -494,6 +504,14 @@ protected List<AffineTransform> applyTranform(RenderingContext c, Box box) {
494
504
495
505
resultTransforms .add (translateToOrigin );
496
506
507
+ applyTransformFunctions (flipFactor , transformList , resultTransforms );
508
+
509
+ resultTransforms .add (translateBackFromOrigin );
510
+
511
+ return c .getOutputDevice ().pushTransforms (resultTransforms );
512
+ }
513
+
514
+ private void applyTransformFunctions (float flipFactor , List <PropertyValue > transformList , List <AffineTransform > resultTransforms ) {
497
515
for (PropertyValue transform : transformList ) {
498
516
String fName = transform .getFunction ().getName ();
499
517
List <PropertyValue > params = transform .getFunction ().getParameters ();
@@ -536,13 +554,9 @@ protected List<AffineTransform> applyTranform(RenderingContext c, Box box) {
536
554
XRLog .layout (Level .WARNING , "translateY function not implemented at this time" );
537
555
}
538
556
}
539
-
540
- resultTransforms .add (translateBackFromOrigin );
541
-
542
- return c .getOutputDevice ().pushTransforms (resultTransforms );
543
557
}
544
558
545
- private Box find (CssContext cssCtx , int absX , int absY , List layers , boolean findAnonymous ) {
559
+ private Box find (CssContext cssCtx , int absX , int absY , List layers , boolean findAnonymous ) {
546
560
Box result = null ;
547
561
// Work backwards since layers are painted forwards and we're looking
548
562
// for the top-most box
@@ -904,7 +918,9 @@ private void position(LayoutContext c) {
904
918
}
905
919
906
920
public List <PageBox > getPages () {
907
- return _pages == null ? Collections .<PageBox >emptyList (): _pages ;
921
+ if (_pages == null )
922
+ return _parent == null ? Collections .<PageBox > emptyList () : _parent .getPages ();
923
+ return _pages ;
908
924
}
909
925
910
926
public void setPages (List <PageBox > pages ) {
0 commit comments