pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1859096 - in /pdfbox/branches/2.0/pdfbox/src: main/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPattern.java test/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPatternTest.java
Date Fri, 10 May 2019 17:50:37 GMT
Author: tilman
Date: Fri May 10 17:50:37 2019
New Revision: 1859096

URL: http://svn.apache.org/viewvc?rev=1859096&view=rev
Log:
PDFBOX-4543: correctly convert array to COSArray (Arrays.asList(array) doesn't convert that
array to a collection), as suggested by Paul Austin; add toString(); add "previously failing"
test

Added:
    pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPatternTest.java
  (with props)
Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPattern.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPattern.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPattern.java?rev=1859096&r1=1859095&r2=1859096&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPattern.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPattern.java
Fri May 10 17:50:37 2019
@@ -20,7 +20,6 @@ import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSInteger;
 
-import org.apache.pdfbox.pdmodel.common.COSArrayList;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 
 import java.util.Arrays;
@@ -60,7 +59,9 @@ public final class PDLineDashPattern imp
     public COSBase getCOSObject()
     {
         COSArray cos = new COSArray();
-        cos.add(COSArrayList.converterToCOSArray(Arrays.asList(array)));
+        COSArray patternArray = new COSArray();
+        patternArray.setFloatArray(array);
+        cos.add(patternArray);
         cos.add(COSInteger.get(phase));
         return cos;
     }
@@ -83,4 +84,10 @@ public final class PDLineDashPattern imp
     {
         return array.clone();
     }
+
+    @Override
+    public String toString()
+    {
+        return "PDLineDashPattern{array=" + Arrays.toString(array) + ", phase=" + phase +
"}";
+    }
 }

Added: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPatternTest.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPatternTest.java?rev=1859096&view=auto
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPatternTest.java
(added)
+++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPatternTest.java
Fri May 10 17:50:37 2019
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *  
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *  
+ *******************************************************************************/
+
+package org.apache.pdfbox.pdmodel.graphics;
+
+import static junit.framework.TestCase.assertEquals;
+import org.apache.pdfbox.cos.COSArray;
+import org.apache.pdfbox.cos.COSFloat;
+import org.apache.pdfbox.cos.COSInteger;
+import org.junit.Test;
+
+/**
+ *
+ * @author Tilman Hausherr
+ */
+public class PDLineDashPatternTest
+{
+
+    /**
+     * Test of getCOSObject method, of class PDLineDashPattern.
+     */
+    @Test
+    public void testGetCOSObject()
+    {
+        COSArray ar = new COSArray();
+        ar.add(COSInteger.ONE);
+        ar.add(COSInteger.TWO);
+        PDLineDashPattern dash = new PDLineDashPattern(ar, 3);
+        COSArray dashBase = (COSArray) dash.getCOSObject();
+        COSArray dashArray = (COSArray) dashBase.getObject(0);
+        assertEquals(2, dashBase.size());
+        assertEquals(2, dashArray.size());
+        assertEquals(new COSFloat(1), dashArray.get(0));
+        assertEquals(new COSFloat(2), dashArray.get(1));
+        assertEquals(COSInteger.THREE, dashBase.get(1));
+        System.out.println(dash);
+    }
+}

Propchange: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/pdmodel/graphics/PDLineDashPatternTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message