You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2016/01/05 15:13:26 UTC

[Bug 58805] New: Header and footer corruption on Run text replacement

https://bz.apache.org/bugzilla/show_bug.cgi?id=58805

            Bug ID: 58805
           Summary: Header and footer corruption on Run text replacement
           Product: POI
           Version: 3.13-FINAL
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HWPF
          Assignee: dev@poi.apache.org
          Reporter: thomas.schwery@gmail.com

Created attachment 33407
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=33407&action=edit
Input file with header and footer tests

The header and footer of doc documents can become corrupted and either crash
Word or present wrong header and footers in the resulting document when runs
have their text replaced.

The attached document is used as a template by the following code that will
replace placeholders with a new text content :

        HWPFDocument doc = new HWPFDocument(new FileInputStream(tstFile));

        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.");
        }

        FileOutputStream fos = new FileOutputStream(outFile);
        doc.write(fos);
        fos.close();

The resulting file displays only part of the text in the header and the footer
is copied from the header and cannot be edited when opened in Word 2013.
LibreOffice 5 displays a short text in the header and copies the table in the
footer with only a small snippet of text.
The _TEST_ in the main part of the document is not replaced, which is as
expected.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org