pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1854146 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
Date Fri, 22 Feb 2019 16:51:35 GMT
Author: tilman
Date: Fri Feb 22 16:51:35 2019
New Revision: 1854146

URL: http://svn.apache.org/viewvc?rev=1854146&view=rev
Log:
PDFBOX-4399: DRY refactoring

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java?rev=1854146&r1=1854145&r2=1854146&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java Fri
Feb 22 16:51:35 2019
@@ -1283,23 +1283,9 @@ public class PageDrawer extends PDFGraph
             return;
         }
 
-        //TODO DRY-refactor this and the code from beginMarkedContentSequence() when PDFBOX-4399
is mostly done
-        PDPropertyList propertyList = annotation.getOptionalContent();
-        if (propertyList instanceof PDOptionalContentGroup)
+        if (isHiddenOCG(annotation.getOptionalContent()))
         {
-            PDOptionalContentGroup group = (PDOptionalContentGroup) propertyList;
-            RenderState printState = group.getRenderState(destination);
-            if (printState == null)
-            {
-                if (!getRenderer().isGroupEnabled(group))
-                {
-                    return;
-                }
-            }
-            else if (RenderState.OFF.equals(printState))
-            {
-                return;
-            }
+            return;
         }
 
         super.showAnnotation(annotation);
@@ -1879,22 +1865,9 @@ public class PageDrawer extends PDFGraph
         {
             return;
         }
-        PDPropertyList propertyList = getPage().getResources().getProperties(tag);
-        if (propertyList instanceof PDOptionalContentGroup)
+        if (isHiddenOCG(getPage().getResources().getProperties(tag)))
         {
-            PDOptionalContentGroup group = (PDOptionalContentGroup) propertyList;
-            RenderState printState = group.getRenderState(destination);
-            if (printState == null)
-            {
-                if (!getRenderer().isGroupEnabled(group))
-                {
-                    nestedHiddenOCGCount = 1;
-                }
-            }
-            else if (RenderState.OFF.equals(printState))
-            {
-                nestedHiddenOCGCount = 1;
-            }
+            nestedHiddenOCGCount = 1;
         }
     }
 
@@ -1914,4 +1887,25 @@ public class PageDrawer extends PDFGraph
     {
         return nestedHiddenOCGCount <= 0;
     }
-}
+
+    private boolean isHiddenOCG(PDPropertyList propertyList)
+    {
+        if (propertyList instanceof PDOptionalContentGroup)
+        {
+            PDOptionalContentGroup group = (PDOptionalContentGroup) propertyList;
+            RenderState printState = group.getRenderState(destination);
+            if (printState == null)
+            {
+                if (!getRenderer().isGroupEnabled(group))
+                {
+                    return true;
+                }
+            }
+            else if (RenderState.OFF.equals(printState))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+}
\ No newline at end of file



Mime
View raw message