Skip to content

Commit 0cca357

Browse files
committed
PDFBOX-6049: refactor
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1927724 13f79535-47bb-0310-9956-ffa450edef68
1 parent fdb00f3 commit 0cca357

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -506,16 +506,7 @@ else if (defaultOverlayPage != null)
506506
PDPage page = inputPDFDocument.getPage(pageNumber - 1);
507507
if (page.getRotation() != 0)
508508
{
509-
LayoutPage rotatedLayoutPage = rotatedDefaultOverlayPagesMap.get(page.getRotation());
510-
if (rotatedLayoutPage == null)
511-
{
512-
// createLayoutPage must be called because we can't reuse the COSStream
513-
rotatedLayoutPage = createLayoutPage(defaultOverlayDocument.getPage(0));
514-
int newRotation = (rotatedLayoutPage.overlayRotation - page.getRotation() + 360) % 360;
515-
rotatedLayoutPage.overlayRotation = newRotation;
516-
rotatedDefaultOverlayPagesMap.put(page.getRotation(), rotatedLayoutPage);
517-
}
518-
return rotatedLayoutPage;
509+
return createAdjustedLayoutPage(page);
519510
}
520511
}
521512
}
@@ -527,6 +518,20 @@ else if (useAllOverlayPages)
527518
return layoutPage;
528519
}
529520

521+
private LayoutPage createAdjustedLayoutPage(PDPage page) throws IOException
522+
{
523+
LayoutPage rotatedLayoutPage = rotatedDefaultOverlayPagesMap.get(page.getRotation());
524+
if (rotatedLayoutPage == null)
525+
{
526+
// createLayoutPage must be called because we can't reuse the COSStream
527+
rotatedLayoutPage = createLayoutPage(defaultOverlayDocument.getPage(0));
528+
int newRotation = (rotatedLayoutPage.overlayRotation - page.getRotation() + 360) % 360;
529+
rotatedLayoutPage.overlayRotation = newRotation;
530+
rotatedDefaultOverlayPagesMap.put(page.getRotation(), rotatedLayoutPage);
531+
}
532+
return rotatedLayoutPage;
533+
}
534+
530535
private PDFormXObject createOverlayFormXObject(LayoutPage layoutPage, PDFCloneUtility cloner)
531536
throws IOException
532537
{
@@ -836,6 +841,5 @@ public void setEvenPageOverlayPDF(PDDocument evenPageOverlayPDF)
836841
public void setAdjustRotation(boolean adjustRotation)
837842
{
838843
this.adjustRotation = adjustRotation;
839-
840844
}
841845
}

0 commit comments

Comments
 (0)