Skip to content

Commit cea82bf

Browse files
committed
PDFBOX-5660: simplify code, as suggested by Valery Bokov; closes #216
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1927848 13f79535-47bb-0310-9956-ffa450edef68
1 parent c95ede5 commit cea82bf

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pdfbox/src/main/java/org/apache/pdfbox/multipdf/Overlay.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,10 @@ else if (defaultOverlayPage != null)
504504
// Note that this segment is only the second best solution to the problem. The best
505505
// would be to make appropriate transforms in calculateAffineTransform()
506506
PDPage page = inputPDFDocument.getPage(pageNumber - 1);
507-
if (page.getRotation() != 0)
507+
int rotation = page.getRotation();
508+
if (rotation != 0)
508509
{
509-
return createAdjustedLayoutPage(page);
510+
return createAdjustedLayoutPage(rotation);
510511
}
511512
}
512513
}
@@ -518,16 +519,16 @@ else if (useAllOverlayPages)
518519
return layoutPage;
519520
}
520521

521-
private LayoutPage createAdjustedLayoutPage(PDPage page) throws IOException
522+
private LayoutPage createAdjustedLayoutPage(int rotation) throws IOException
522523
{
523-
LayoutPage rotatedLayoutPage = rotatedDefaultOverlayPagesMap.get(page.getRotation());
524+
LayoutPage rotatedLayoutPage = rotatedDefaultOverlayPagesMap.get(rotation);
524525
if (rotatedLayoutPage == null)
525526
{
526527
// createLayoutPage must be called because we can't reuse the COSStream
527528
rotatedLayoutPage = createLayoutPage(defaultOverlayDocument.getPage(0));
528-
int newRotation = (rotatedLayoutPage.overlayRotation - page.getRotation() + 360) % 360;
529+
int newRotation = (rotatedLayoutPage.overlayRotation - rotation + 360) % 360;
529530
rotatedLayoutPage.overlayRotation = newRotation;
530-
rotatedDefaultOverlayPagesMap.put(page.getRotation(), rotatedLayoutPage);
531+
rotatedDefaultOverlayPagesMap.put(rotation, rotatedLayoutPage);
531532
}
532533
return rotatedLayoutPage;
533534
}

0 commit comments

Comments
 (0)