Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
phip1611 committed Sep 18, 2020
2 parents e25e845 + a997ee6 commit 2411f97
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# 1.0.2
Dependency upgrades + small fixes + definitely works with Java 8.
Using `docx4j-JAXB-ReferenceImpl` @ `8.x`

# 1.0.1
Initial release on Maven
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ This means we can't just do a simple replace on a `Text`-object (a Docx4J-Type).
"${PLACE_OF_BIRTH}", "GERMANY"
));

### Requirements

**Docx4JSRUtil** (1.0.2) uses Java 8 as minimum version and should work with all
higher Java versions as well. It uses `docx4j-JAXB-ReferenceImpl` instead of `MOXy`.
There are no technical reasons for this limitation.

### How it works internally

1. It retrieves the list of all `Text`-objects (in correct order) from Docx4J
Expand Down
7 changes: 1 addition & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,9 @@
<dependencies>
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-JAXB-MOXy</artifactId>
<artifactId>docx4j-JAXB-ReferenceImpl</artifactId>
<version>8.2.3</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/phip1611/StringFindUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ public static class FoundResult {
/**
* Index inside source string where occurrence starts.
*/
private int start;
private final int start;

/**
* Index inside source string where occurrence ends.
*/
private int end;
private final int end;

/**
* Constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@
import java.util.Map;

/**
* This is not a test JUnit should execute but a test for
* Processes a user specified docx file and writes the
* transformed document into the specified location.
*
* This IS NOT a test JUnit should execute but a test for
* humans (to execute from your IDE). This way you can
* easily specify a path and check the processed .docx.
*/
public class ProcessDocxTest {
public class ProcessDocxUserFileTest {

private static final String SOURCE_DOCX_PATH = "src/test/resources/source.docx";
private static final String DEST_DOCX_PATH = "/Users/phip1611/Desktop/test-processed.docx";
private static final String DEST_DOCX_PATH = "/Users/<replace user>/Desktop/test-processed.docx";
// private static final String DEST_DOCX_PATH = "C:/Users/<replace user>/Desktop/test-processed.docx";

@Test
// Unignore to execute and test this;
Expand All @@ -50,7 +54,7 @@ public class ProcessDocxTest {
public void processDocxTest() {
Map<String, String> placeholderMap = new HashMap<>();
// Line breaks works as well
placeholderMap.put("${NAME}", "Phi\nlipp");
placeholderMap.put("${NAME}", "Philipp");
placeholderMap.put("${SURNAME}", "Schuster");
placeholderMap.put("${PLACE_OF_BIRTH}", "GERMANY");

Expand All @@ -63,6 +67,7 @@ public void processDocxTest() {

sourceDocxDoc.save(new File(DEST_DOCX_PATH));
} catch (Docx4JException e) {
e.printStackTrace();
Assert.fail("Exception occurred!");
}
}
Expand Down

0 comments on commit 2411f97

Please sign in to comment.