Skip to content

Commit a8dd2a4

Browse files
committed
Revert "fixed findFieldName method not giving the result more than one time."
This reverts commit 07f9561.
1 parent 07f9561 commit a8dd2a4

File tree

4 files changed

+11
-38
lines changed

4 files changed

+11
-38
lines changed

forms/src/main/java/com/itextpdf/forms/xfa/XfaForm.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,17 @@ This file is part of the iText (R) project.
5555
import com.itextpdf.kernel.pdf.PdfVersion;
5656
import com.itextpdf.kernel.pdf.VersionConforming;
5757
import com.itextpdf.kernel.xmp.XmlDomWriter;
58+
import org.w3c.dom.Document;
59+
import org.w3c.dom.Element;
60+
import org.w3c.dom.Node;
61+
import org.w3c.dom.NodeList;
62+
import org.xml.sax.EntityResolver;
63+
import org.xml.sax.InputSource;
64+
import org.xml.sax.SAXException;
5865

5966
import javax.xml.parsers.DocumentBuilder;
6067
import javax.xml.parsers.DocumentBuilderFactory;
6168
import javax.xml.parsers.ParserConfigurationException;
62-
6369
import java.io.ByteArrayInputStream;
6470
import java.io.ByteArrayOutputStream;
6571
import java.io.File;
@@ -71,14 +77,6 @@ This file is part of the iText (R) project.
7177
import java.util.HashMap;
7278
import java.util.Map;
7379

74-
import org.w3c.dom.Document;
75-
import org.w3c.dom.Element;
76-
import org.w3c.dom.Node;
77-
import org.w3c.dom.NodeList;
78-
import org.xml.sax.EntityResolver;
79-
import org.xml.sax.InputSource;
80-
import org.xml.sax.SAXException;
81-
8280
/**
8381
* Processes XFA forms.
8482
*/
@@ -333,14 +331,10 @@ public boolean isXfaPresent() {
333331
* @return the complete name or <CODE>null</CODE> if not found
334332
*/
335333
public String findFieldName(String name) {
336-
if (acroFieldsSom == null && xfaPresent && datasetsSom != null ) {
334+
if (acroFieldsSom == null && xfaPresent) {
337335
acroFieldsSom = new AcroFieldsSearch(datasetsSom.getName2Node().keySet());
338-
}
339-
340-
if (acroFieldsSom != null && xfaPresent) {
341336
return acroFieldsSom.getAcroShort2LongName().containsKey(name) ? acroFieldsSom.getAcroShort2LongName().get(name) : acroFieldsSom.inverseSearchGlobal(Xml2Som.splitParts(name));
342337
}
343-
344338
return null;
345339
}
346340

forms/src/test/java/com/itextpdf/forms/xfa/XFAFormTest.java

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,14 @@ This file is part of the iText (R) project.
4949
import com.itextpdf.kernel.utils.CompareTool;
5050
import com.itextpdf.test.ExtendedITextTest;
5151
import com.itextpdf.test.annotations.type.IntegrationTest;
52-
53-
import java.io.FileInputStream;
54-
import java.io.IOException;
55-
5652
import org.junit.Assert;
5753
import org.junit.BeforeClass;
5854
import org.junit.Test;
5955
import org.junit.experimental.categories.Category;
6056

57+
import java.io.FileInputStream;
58+
import java.io.IOException;
59+
6160
@Category(IntegrationTest.class)
6261
public class XFAFormTest extends ExtendedITextTest {
6362

@@ -120,25 +119,5 @@ public void readXFAFormTest() throws IOException {
120119
PdfAcroForm.getAcroForm(pdfDocument, true);
121120
}
122121

123-
@Test
124-
public void findFieldName() throws IOException {
125-
String inFileName = sourceFolder + "TextField1.pdf";
126-
PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFileName));
127-
PdfAcroForm acroForm = PdfAcroForm.getAcroForm(pdfDocument, true);
128-
XfaForm xfaForm = acroForm.getXfaForm();
129-
xfaForm.findFieldName("TextField1");
130-
String secondRun = xfaForm.findFieldName("TextField1");
131-
Assert.assertNotNull(secondRun);
132-
}
133-
134-
@Test
135-
public void findFieldNameWithoutDataSet() throws IOException {
136-
String inFileName = sourceFolder + "TextField1_empty.pdf";
137-
PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFileName));
138-
PdfAcroForm acroForm = PdfAcroForm.getAcroForm(pdfDocument, true);
139-
XfaForm xfaForm = acroForm.getXfaForm();
140-
String name = xfaForm.findFieldName("TextField1");
141-
Assert.assertNull(name);
142-
}
143122

144123
}
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)