Author: ssteiner
Date: Fri Mar  3 13:00:22 2017
New Revision: 1785288

URL: http://svn.apache.org/viewvc?rev=1785288&view=rev
Log:
Clean up API calls and fix for findbugs 3

Modified:
    
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/AbstractPDFBoxHandler.java
    
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFSingleByteFont.java
    
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PreloaderPDF.java
    
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/FOPPDFSingleMultiByteFontTestCase.java
    
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java
    
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFRotateTestCase.java

Modified: 
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/AbstractPDFBoxHandler.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/AbstractPDFBoxHandler.java?rev=1785288&r1=1785287&r2=1785288&view=diff
==============================================================================
--- 
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/AbstractPDFBoxHandler.java
 (original)
+++ 
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/AbstractPDFBoxHandler.java
 Fri Mar  3 13:00:22 2017
@@ -93,7 +93,7 @@ public abstract class AbstractPDFBoxHand
 
         Map<Object, Object> objectCachePerFile = 
getObjectCache(getImagePath(originalImageUri), userAgent);
 
-        PDPage page = pddoc.getDocumentCatalog().getPages().get(selectedPage);
+        PDPage page = pddoc.getPage(selectedPage);
 
         if (targetPage.getPDFResources().getParentResources() == null) {
             PDFResources res = pdfDoc.getFactory().makeResources();

Modified: 
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFSingleByteFont.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFSingleByteFont.java?rev=1785288&r1=1785287&r2=1785288&view=diff
==============================================================================
--- 
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFSingleByteFont.java
 (original)
+++ 
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/FOPPDFSingleByteFont.java
 Fri Mar  3 13:00:22 2017
@@ -357,7 +357,7 @@ public class FOPPDFSingleByteFont extend
         for (int i = fontForEnc.getFirstChar(); i <= fontForEnc.getLastChar(); 
i++) {
             if (codeToName.keySet().contains(i)) {
                 String s = codeToName.get(i);
-                if (!added.contains(s) || (added.contains(s) && 
!encodingMap.containsKey(i))) {
+                if (!added.contains(s) || !encodingMap.containsKey(i)) {
                     if (!encodingMap.containsKey(i)) {
                         encodingMap.put(i, s);
                     } else {

Modified: 
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PreloaderPDF.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PreloaderPDF.java?rev=1785288&r1=1785287&r2=1785288&view=diff
==============================================================================
--- 
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PreloaderPDF.java
 (original)
+++ 
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PreloaderPDF.java
 Fri Mar  3 13:00:22 2017
@@ -105,7 +105,7 @@ public class PreloaderPDF extends Abstra
                     + ") does not exist in the PDF file. The document has "
                     + pddoc.getNumberOfPages() + " pages.");
         }
-        PDPage page = pddoc.getDocumentCatalog().getPages().get(selectedPage);
+        PDPage page = pddoc.getPage(selectedPage);
         PDRectangle mediaBox = page.getMediaBox();
         PDRectangle cropBox = page.getCropBox();
         PDRectangle viewBox = cropBox != null ? cropBox : mediaBox;

Modified: 
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/FOPPDFSingleMultiByteFontTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/FOPPDFSingleMultiByteFontTestCase.java?rev=1785288&r1=1785287&r2=1785288&view=diff
==============================================================================
--- 
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/FOPPDFSingleMultiByteFontTestCase.java
 (original)
+++ 
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/FOPPDFSingleMultiByteFontTestCase.java
 Fri Mar  3 13:00:22 2017
@@ -45,7 +45,7 @@ import org.apache.fop.render.pdf.pdfbox.
 
 public class FOPPDFSingleMultiByteFontTestCase {
     private COSDictionary getFont(PDDocument doc, String internalname) throws 
IOException {
-        PDPage page = doc.getDocumentCatalog().getPages().get(0);
+        PDPage page = doc.getPage(0);
         PDResources sourcePageResources = page.getResources();
         COSDictionary fonts = 
(COSDictionary)sourcePageResources.getCOSObject().getDictionaryObject(COSName.FONT);
         return (COSDictionary) fonts.getDictionaryObject(internalname);

Modified: 
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java?rev=1785288&r1=1785287&r2=1785288&view=diff
==============================================================================
--- 
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java
 (original)
+++ 
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFBoxAdapterTestCase.java
 Fri Mar  3 13:00:22 2017
@@ -159,7 +159,7 @@ public class PDFBoxAdapterTestCase {
             if (font.getFontType() == FontType.TYPE1C || font.getFontType() == 
FontType.CIDTYPE0) {
                 byte[] data = IOUtils.toByteArray(is);
                 CFFParser p = new CFFParser();
-                p.parse(data).get(0);
+                p.parse(data);
             } else if (font.getFontType() == FontType.TRUETYPE) {
                 TTFParser parser = new TTFParser();
                 parser.parse(is);
@@ -180,7 +180,7 @@ public class PDFBoxAdapterTestCase {
 
     private String writeText(FontInfo fi, String pdf) throws IOException {
         PDDocument doc = PDDocument.load(new File(pdf));
-        PDPage page = doc.getDocumentCatalog().getPages().get(0);
+        PDPage page = doc.getPage(0);
         AffineTransform at = new AffineTransform();
         String c = getPDFBoxAdapter(true).createStreamFromPDFBoxPage(doc, 
page, pdf, at, fi, new Rectangle());
 //        PDResources sourcePageResources = page.findResources();
@@ -199,7 +199,7 @@ public class PDFBoxAdapterTestCase {
         PDFBoxAdapter adapter = new PDFBoxAdapter(pdfpage, new HashMap(), new 
HashMap<Integer, PDFArray>());
         adapter.setCurrentMCID(5);
         PDDocument doc = PDDocument.load(new File(HELLOTagged));
-        PDPage page = doc.getDocumentCatalog().getPages().get(0);
+        PDPage page = doc.getPage(0);
         AffineTransform at = new AffineTransform();
         Rectangle r = new Rectangle(0, 1650, 842000, 595000);
         String stream = adapter.createStreamFromPDFBoxPage(doc, page, "key", 
at, null, r);
@@ -215,7 +215,7 @@ public class PDFBoxAdapterTestCase {
         pdfpage.setObjectNumber(1);
         PDFBoxAdapter adapter = new PDFBoxAdapter(pdfpage, new HashMap(), new 
HashMap<Integer, PDFArray>());
         PDDocument doc = PDDocument.load(new File(ANNOT));
-        PDPage page = doc.getDocumentCatalog().getPages().get(0);
+        PDPage page = doc.getPage(0);
         AffineTransform at = new AffineTransform();
         Rectangle r = new Rectangle(0, 1650, 842000, 595000);
         ByteArrayOutputStream os = new ByteArrayOutputStream();
@@ -231,7 +231,7 @@ public class PDFBoxAdapterTestCase {
     public void testAnnot2() throws Exception {
         PDFBoxAdapter adapter = getPDFBoxAdapter(false);
         PDDocument doc = PDDocument.load(new File(ANNOT));
-        PDPage page = doc.getDocumentCatalog().getPages().get(0);
+        PDPage page = doc.getPage(0);
         COSArray annots = (COSArray) 
page.getCOSObject().getDictionaryObject(COSName.ANNOTS);
         COSDictionary dict = (COSDictionary) 
((COSObject)annots.get(0)).getObject();
         dict.setItem(COSName.PARENT, COSInteger.ONE);
@@ -251,7 +251,7 @@ public class PDFBoxAdapterTestCase {
         Map<Integer, PDFArray> pageNumbers = new HashMap<Integer, PDFArray>();
         PDFBoxAdapter adapter = new PDFBoxAdapter(pdfpage, new HashMap(), 
pageNumbers);
         PDDocument doc = PDDocument.load(new File(LINK));
-        PDPage page = doc.getDocumentCatalog().getPages().get(0);
+        PDPage page = doc.getPage(0);
         AffineTransform at = new AffineTransform();
         Rectangle r = new Rectangle(0, 1650, 842000, 595000);
         String stream = adapter.createStreamFromPDFBoxPage(doc, page, "key", 
at, null, r);
@@ -273,7 +273,7 @@ public class PDFBoxAdapterTestCase {
         Map<Integer, PDFArray> pageNumbers = new HashMap<Integer, PDFArray>();
         PDFBoxAdapter adapter = new PDFBoxAdapter(pdfpage, new HashMap(), 
pageNumbers);
         PDDocument doc = PDDocument.load(new File(XFORM));
-        PDPage page = doc.getDocumentCatalog().getPages().get(0);
+        PDPage page = doc.getPage(0);
         AffineTransform at = new AffineTransform();
         Rectangle r = new Rectangle(0, 1650, 842000, 595000);
         adapter.createStreamFromPDFBoxPage(doc, page, "key", at, new 
FontInfo(), r);
@@ -412,7 +412,7 @@ public class PDFBoxAdapterTestCase {
         PDFBoxAdapter adapter = new PDFBoxAdapter(
                 pdfpage, objectCachePerFile, new HashMap<Integer, PDFArray>(), 
pdfCache);
         PDDocument doc = PDDocument.load(new File(LOOP));
-        PDPage page = doc.getDocumentCatalog().getPages().get(0);
+        PDPage page = doc.getPage(0);
         adapter.createStreamFromPDFBoxPage(doc, page, "key", new 
AffineTransform(), null, new Rectangle());
         doc.close();
 

Modified: 
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFRotateTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFRotateTestCase.java?rev=1785288&r1=1785287&r2=1785288&view=diff
==============================================================================
--- 
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFRotateTestCase.java
 (original)
+++ 
xmlgraphics/fop-pdf-images/trunk/test/java/org/apache/fop/render/pdf/PDFRotateTestCase.java
 Fri Mar  3 13:00:22 2017
@@ -76,7 +76,7 @@ public class PDFRotateTestCase {
     private AffineTransform getTransform(int angle) throws IOException {
         PDFBoxAdapter adapter = PDFBoxAdapterTestCase.getPDFBoxAdapter(false);
         PDDocument doc = PDDocument.load(new 
File(PDFBoxAdapterTestCase.ROTATE));
-        PDPage page = doc.getDocumentCatalog().getPages().get(0);
+        PDPage page = doc.getPage(0);
         page.setRotation(angle);
         AffineTransform at = new AffineTransform();
         Rectangle r = new Rectangle(0, 1650, 842000, 595000);



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-h...@xmlgraphics.apache.org

Reply via email to