[Git][java-team/libsambox-java][master] 4 commits: New upstream version 2.2.11
Markus Koschany
gitlab at salsa.debian.org
Sun Jan 31 14:54:38 GMT 2021
Markus Koschany pushed to branch master at Debian Java Maintainers / libsambox-java
Commits:
87c5dff0 by Markus Koschany at 2021-01-31T15:50:19+01:00
New upstream version 2.2.11
- - - - -
f06552ec by Markus Koschany at 2021-01-31T15:50:22+01:00
Update upstream source from tag 'upstream/2.2.11'
Update to upstream version '2.2.11'
with Debian dir 80f57ee7f37e9b3c6f103cdd44f0282f39f01c03
- - - - -
8938c557 by Markus Koschany at 2021-01-31T15:50:55+01:00
Update copyright years
- - - - -
16c8836e by Markus Koschany at 2021-01-31T15:51:21+01:00
Update changelog
- - - - -
8 changed files:
- .travis.yml
- debian/changelog
- debian/copyright
- pom.xml
- src/main/java/org/sejda/sambox/pdmodel/PDPage.java
- src/main/java/org/sejda/sambox/pdmodel/PDPageTree.java
- src/main/java/org/sejda/sambox/pdmodel/common/function/PDFunctionType3.java
- src/main/java/org/sejda/sambox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
Changes:
=====================================
.travis.yml
=====================================
@@ -1,4 +1,7 @@
language: java
+arch:
+ - AMD64
+ - ppc64le
sudo: false
jdk:
- openjdk8
=====================================
debian/changelog
=====================================
@@ -1,3 +1,9 @@
+libsambox-java (2.2.11-1) unstable; urgency=medium
+
+ * New upstream version 2.2.11.
+
+ -- Markus Koschany <apo at debian.org> Sun, 31 Jan 2021 15:51:07 +0100
+
libsambox-java (2.2.6-1) unstable; urgency=medium
* New upstream version 2.2.6.
=====================================
debian/copyright
=====================================
@@ -5,7 +5,7 @@ Files-Excluded:
src/test/*
Files: *
-Copyright: 2016-2020, Andrea Vacondio
+Copyright: 2016-2021, Andrea Vacondio
2010-2017, The Apache Software Foundation
License: Apache-2.0
@@ -40,7 +40,7 @@ Copyright: 2007-2010, basICColor GmbH
License: zlib
Files: debian/*
-Copyright: 2017-2020, Markus Koschany <apo at debian.org>
+Copyright: 2017-2021, Markus Koschany <apo at debian.org>
License: Apache-2.0
License: Apache-2.0
=====================================
pom.xml
=====================================
@@ -5,7 +5,7 @@
<artifactId>sambox</artifactId>
<packaging>jar</packaging>
<name>sambox</name>
- <version>2.2.6</version>
+ <version>2.2.11</version>
<description>An Apache PDFBox fork intended to be used as PDF processor for Sejda and PDFsam related projects</description>
<url>http://www.sejda.org</url>
@@ -33,7 +33,7 @@
<connection>scm:git:git at github.com:torakiki/sambox.git</connection>
<developerConnection>scm:git:git at github.com:torakiki/sambox.git</developerConnection>
<url>scm:git:git at github.com:torakiki/sambox.git</url>
- <tag>v2.2.6</tag>
+ <tag>v2.2.11</tag>
</scm>
<developers>
=====================================
src/main/java/org/sejda/sambox/pdmodel/PDPage.java
=====================================
@@ -77,6 +77,7 @@ public class PDPage implements COSObjectable, PDContentStream
private PDResources pageResources;
private ResourceCache resourceCache;
private PDRectangle mediaBox;
+ private COSDictionary pageTreeParent;
/**
* Creates a new PDPage instance for embedding, with a size of U.S. Letter (8.5 x 11 inches).
@@ -119,6 +120,18 @@ public class PDPage implements COSObjectable, PDContentStream
this.resourceCache = resourceCache;
}
+ /**
+ * Creates a new instance of PDPage for reading.
+ *
+ * @param pageDictionary A page dictionary in a PDF document.
+ */
+ PDPage(COSDictionary pageDictionary, ResourceCache resourceCache, COSDictionary pageTreeParent)
+ {
+ page = pageDictionary;
+ this.resourceCache = resourceCache;
+ this.pageTreeParent = pageTreeParent;
+ }
+
/**
* Convert this standard java object to a COS object.
*
@@ -220,7 +233,7 @@ public class PDPage implements COSObjectable, PDContentStream
if (pageResources == null)
{
pageResources = new PDResources(ofNullable(
- (COSDictionary) PDPageTree.getInheritableAttribute(page, COSName.RESOURCES))
+ (COSDictionary) PDPageTree.getInheritableAttribute(page, COSName.RESOURCES, COSDictionary.class))
.orElseGet(() -> {
COSDictionary emptyRes = new COSDictionary();
// it's illegal for a page to not have resources, either direct or inherited. According
@@ -929,4 +942,7 @@ public class PDPage implements COSObjectable, PDContentStream
});
}
+ public COSDictionary getPageTreeParent() {
+ return pageTreeParent;
+ }
}
=====================================
src/main/java/org/sejda/sambox/pdmodel/PDPageTree.java
=====================================
@@ -22,15 +22,7 @@ import static java.util.Optional.ofNullable;
import static java.util.stream.Collectors.toList;
import static org.sejda.commons.util.RequireUtils.requireNotNullArg;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Objects;
-import java.util.Queue;
-import java.util.Spliterator;
-import java.util.Spliterators;
+import java.util.*;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
@@ -104,6 +96,24 @@ public class PDPageTree implements COSObjectable, Iterable<PDPage>
this.document = document;
}
+ /**
+ * Similar to {@link #getInheritableAttribute(COSDictionary, COSName)} but also checks the returned element
+ * matches the expected type class
+ * @param node
+ * @param key
+ * @param clazz expected type class
+ * @param <T>
+ * @return
+ */
+ public static <T extends COSBase> COSBase getInheritableAttribute(COSDictionary node, COSName key, Class<T> clazz) {
+ COSBase result = getInheritableAttribute(node, key);
+ if(clazz.isInstance(result)) {
+ return result;
+ } else {
+ return null;
+ }
+ }
+
/**
* Returns the given attribute, inheriting from parent tree nodes if necessary.
*
@@ -278,12 +288,13 @@ public class PDPageTree implements COSObjectable, Iterable<PDPage>
*/
public PDPage get(int index)
{
- COSDictionary dict = get(index + 1, root, 0);
+ PageAndPageTreeParent res = get(index + 1, root, 0, null);
+ COSDictionary dict = res.node;
sanitizeType(dict);
ResourceCache resourceCache = document != null ? document.getResourceCache() : null;
- return new PDPage(dict, resourceCache);
+ return new PDPage(dict, resourceCache, res.parent);
}
private static void sanitizeType(COSDictionary dictionary)
@@ -307,9 +318,10 @@ public class PDPageTree implements COSObjectable, Iterable<PDPage>
* @param pageNum 1-based page number
* @param node page tree node to search
* @param encountered number of pages encountered so far
+ * @param pageTreeParent the parent node, as determined traversing the page tree top -> down
* @return COS dictionary of the Page object
*/
- private COSDictionary get(int pageNum, COSDictionary node, int encountered)
+ private PageAndPageTreeParent get(int pageNum, COSDictionary node, int encountered, COSDictionary pageTreeParent)
{
if (pageNum < 0)
{
@@ -333,7 +345,7 @@ public class PDPageTree implements COSObjectable, Iterable<PDPage>
if (pageNum <= encountered + kidCount)
{
// it's this kid
- return get(pageNum, kid, encountered);
+ return get(pageNum, kid, encountered, node);
}
encountered += kidCount;
}
@@ -344,7 +356,7 @@ public class PDPageTree implements COSObjectable, Iterable<PDPage>
if (pageNum == encountered)
{
// it's this page
- return get(pageNum, kid, encountered);
+ return get(pageNum, kid, encountered, node);
}
}
}
@@ -359,7 +371,7 @@ public class PDPageTree implements COSObjectable, Iterable<PDPage>
}
if (encountered == pageNum)
{
- return node;
+ return new PageAndPageTreeParent(node, pageTreeParent);
}
throw new PageNotFoundException("Unable to find page " + pageNum + " in " + getSourcePath(),
@@ -457,8 +469,8 @@ public class PDPageTree implements COSObjectable, Iterable<PDPage>
*/
public void remove(int index)
{
- COSDictionary node = get(index + 1, root, 0);
- remove(node);
+ PageAndPageTreeParent res = get(index + 1, root, 0, null);
+ remove(res.node);
}
/**
@@ -532,8 +544,12 @@ public class PDPageTree implements COSObjectable, Iterable<PDPage>
public void insertBefore(PDPage newPage, PDPage nextPage)
{
COSDictionary nextPageDict = nextPage.getCOSObject();
- COSDictionary parentDict = nextPageDict.getDictionaryObject(COSName.PARENT,
- COSDictionary.class);
+ COSDictionary parentDict = nextPageDict.getDictionaryObject(COSName.PARENT, COSDictionary.class);
+ if(nextPage.getPageTreeParent() != null)
+ {
+ parentDict = nextPage.getPageTreeParent();
+ }
+
COSArray kids = parentDict.getDictionaryObject(COSName.KIDS, COSArray.class);
boolean found = false;
for (int i = 0; i < kids.size(); ++i)
@@ -566,6 +582,11 @@ public class PDPageTree implements COSObjectable, Iterable<PDPage>
COSDictionary prevPageDict = prevPage.getCOSObject();
COSDictionary parentDict = prevPageDict.getDictionaryObject(COSName.PARENT,
COSDictionary.class);
+ if(prevPage.getPageTreeParent() != null)
+ {
+ parentDict = prevPage.getPageTreeParent();
+ }
+
COSArray kids = parentDict.getDictionaryObject(COSName.KIDS, COSArray.class);
boolean found = false;
for (int i = 0; i < kids.size(); ++i)
@@ -595,4 +616,19 @@ public class PDPageTree implements COSObjectable, Iterable<PDPage>
parentDict = (COSDictionary) parentDict.getDictionaryObject(COSName.PARENT);
} while (parentDict != null);
}
+
+ /**
+ * A tuple of a page and the parent found when traversing the page tree top down.
+ * NOTE: The page tree parent can be different from page.PARENT (for invalid documents)
+ * hence the need for this class when adding new pages and having to increment kids counters in the page tree
+ */
+ public static class PageAndPageTreeParent {
+ public final COSDictionary node;
+ public final COSDictionary parent;
+
+ public PageAndPageTreeParent(COSDictionary node, COSDictionary parent) {
+ this.node = node;
+ this.parent = parent;
+ }
+ }
}
=====================================
src/main/java/org/sejda/sambox/pdmodel/common/function/PDFunctionType3.java
=====================================
@@ -77,7 +77,11 @@ public class PDFunctionType3 extends PDFunction
functionsArray = new PDFunction[ar.size()];
for (int i = 0; i < ar.size(); ++i)
{
- functionsArray[i] = PDFunction.create(ar.getObject(i));
+ COSBase base = ar.getObject(i);
+ if (base != null)
+ {
+ functionsArray[i] = PDFunction.create(base);
+ }
}
}
=====================================
src/main/java/org/sejda/sambox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
=====================================
@@ -504,7 +504,7 @@ public class AppearanceGeneratorHelper
// always re-calculate the fontSize for text fields
// because sometimes the field value changes to a longer string, which won't fit the field anymore when drawn
// using the previous font size
- if (field instanceof PDTextField)
+ if (field instanceof PDTextField && !((PDTextField) field).isMultiline())
{
recalculateFontSize = true;
}
View it on GitLab: https://salsa.debian.org/java-team/libsambox-java/-/compare/bc82479a5654be541fa4756fdd6b44d5101f53a8...16c8836efbcc21ef84f405b47713d765001bc134
--
View it on GitLab: https://salsa.debian.org/java-team/libsambox-java/-/compare/bc82479a5654be541fa4756fdd6b44d5101f53a8...16c8836efbcc21ef84f405b47713d765001bc134
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20210131/ef067f65/attachment.html>
More information about the pkg-java-commits
mailing list