From 27e0325b19d7327f55a02a6e0f03dc5a0c439636 Mon Sep 17 00:00:00 2001 From: Tilman Hausherr Date: Mon, 14 Aug 2023 06:17:40 +0000 Subject: [PATCH] =?UTF-8?q?PDFBOX-5637:=20use=20cache=20as=20suggested=20b?= =?UTF-8?q?y=20Andreas=20Lehmk=C3=BChler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1911632 13f79535-47bb-0310-9956-ffa450edef68 --- .../pdfbox/pdmodel/interactive/form/PDAcroForm.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java index 73845eae219..2e55ed43770 100644 --- a/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java +++ b/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java @@ -687,9 +687,10 @@ public void setAppendOnly(boolean appendOnly) * Return the calculation order in which field values should be recalculated when the value of * any field changes. (Read about "Trigger Events" in the PDF specification) * - * @return field list. Note these objects are not identical to PDField objects - * retrieved from other methods, you'd need to call {@link #getCOSObject()} to check for - * identity; and the list is not backed by the /CO COSArray in the document. + * @return field list. Note these objects may not be identical to PDField objects retrieved from + * other methods (depending on cache setting). The best strategie is to call + * {@link #getCOSObject()} to check for identity. The list is not backed by the /CO COSArray in + * the document. */ public List getCalcOrder() { @@ -699,13 +700,13 @@ public List getCalcOrder() return Collections.emptyList(); } - PDFieldTree fieldTree = getFieldTree(); + Iterable fields = isCachingFields() ? fieldCache.values() : getFieldTree(); List actuals = new ArrayList<>(); for (int i = 0; i < co.size(); i++) { COSBase item = co.getObject(i); - for (PDField field : fieldTree) + for (PDField field : fields) { if (field.getCOSObject() == item) {