Skip to content

Commit

Permalink
Merge pull request #171 from rototor/fix-css-rotate-multipage
Browse files Browse the repository at this point in the history
Testcase and fix for rotation on the second and following pages.
  • Loading branch information
danfickle authored Feb 14, 2018
2 parents c8ff009 + 43689c2 commit 09833be
Show file tree
Hide file tree
Showing 6 changed files with 3,440 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,16 @@ protected List<AffineTransform> applyTranform(RenderingContext c, Box box) {
RectPropertySet margin = c.getPage().getMargin(c);
relTranslateX += margin.left();
relTranslateY += margin.top();

/*
* We must apply the top/bottom margins from the previous pages, otherwise
* our transform center is wrong.
*/
for (int i = 0; i < c.getPageNo(); i++) {
RectPropertySet prevMargin = getPages().get(i).getMargin(c);
relTranslateY += prevMargin.top() + prevMargin.bottom();
}


MarginBoxName[] marginBoxNames = c.getPage().getCurrentMarginBoxNames();
if (marginBoxNames != null) {
Expand Down Expand Up @@ -494,6 +504,14 @@ protected List<AffineTransform> applyTranform(RenderingContext c, Box box) {

resultTransforms.add(translateToOrigin);

applyTransformFunctions(flipFactor, transformList, resultTransforms);

resultTransforms.add(translateBackFromOrigin);

return c.getOutputDevice().pushTransforms(resultTransforms);
}

private void applyTransformFunctions(float flipFactor, List<PropertyValue> transformList, List<AffineTransform> resultTransforms) {
for (PropertyValue transform : transformList) {
String fName = transform.getFunction().getName();
List<PropertyValue> params = transform.getFunction().getParameters();
Expand Down Expand Up @@ -536,13 +554,9 @@ protected List<AffineTransform> applyTranform(RenderingContext c, Box box) {
XRLog.layout(Level.WARNING, "translateY function not implemented at this time");
}
}

resultTransforms.add(translateBackFromOrigin);

return c.getOutputDevice().pushTransforms(resultTransforms);
}

private Box find(CssContext cssCtx, int absX, int absY, List layers, boolean findAnonymous) {
private Box find(CssContext cssCtx, int absX, int absY, List layers, boolean findAnonymous) {
Box result = null;
// Work backwards since layers are painted forwards and we're looking
// for the top-most box
Expand Down Expand Up @@ -904,7 +918,9 @@ private void position(LayoutContext c) {
}

public List<PageBox> getPages() {
return _pages == null ? Collections.<PageBox>emptyList(): _pages;
if (_pages == null)
return _parent == null ? Collections.<PageBox> emptyList() : _parent.getPages();
return _pages;
}

public void setPages(List<PageBox> pages) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ public static void main(String[] args) throws Exception {

runTestCase("math-ml");

/*
* Broken rotate() on the second page
*/
runTestCase("RepeatedTableTransformSample");
/* Add additional test cases here. */
}

Expand Down
Loading

0 comments on commit 09833be

Please sign in to comment.