Skip to content

Commit

Permalink
Add test for bug 58805
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1923055 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
centic9 committed Jan 11, 2025
1 parent 38e7fe6 commit 534d24d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Licensed to the Apache Software Foundation (ASF) under one or more

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -784,4 +786,21 @@ void test64132() throws IOException {
assertNotNull(pictures);
}
}

//
@Test
void test58805() throws IOException {
try (HWPFDocument doc = openSampleFile("header_footer_replace.doc")) {

Range oRange = doc.getHeaderStoryRange();
for (int i = 0; i < oRange.numCharacterRuns(); i++) {
CharacterRun run = oRange.getCharacterRun(i);
run.replaceText("_TEST_", "This text is longer than the initial text. It goes on and on without interruption.");
}

try (FileOutputStream fos = new FileOutputStream(new File("/tmp/test.doc"))) {
doc.write(fos);
}
}
}
}
Binary file added test-data/document/header_footer_replace.doc
Binary file not shown.

0 comments on commit 534d24d

Please sign in to comment.