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 2015/03/15 15:19:57 UTC

[Bug 53528] Inserting consecutive character runs with different character properties not works properly

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

--- Comment #1 from Alex <st...@gmail.com> ---
Confirm the issue still exists in:

    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi-scratchpad</artifactId>
      <version>3.11</version>
    </dependency>

Have changed the example to see what each CharacterRun is:

import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.usermodel.*;
import java.io.*;

public class WordWriter {
    public static void main(String[] args) throws IOException {
        final HWPFDocument doc = new HWPFDocument(new
FileInputStream("empty.dot"));

        final Range range = doc.getRange();

        final CharacterRun cr1 = range.insertAfter("[Bold]");
        cr1.setBold(true);
        System.out.println(cr1.text());

        final CharacterRun cr2 = cr1.insertAfter("[Normal]");
        cr2.setBold(false);
        System.out.println(cr2.text());

        doc.write(new FileOutputStream("output.doc"));
    }
}

It shows:
[Bold]
[Bold][Normal]

It seems insertAfter returns the resulting string. The question is how to
reference the string that was just inserted.

Would be pleased if anyone tells me how to insert two text fragments with
different formatting in HWPF.

-- 
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