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 2018/07/31 15:28:28 UTC

[Bug 62589] New: Creating of simple fields when writing DOCX doesn't work in current code

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

            Bug ID: 62589
           Summary: Creating of simple fields when writing DOCX doesn't
                    work in current code
           Product: POI
           Version: 4.0-dev
          Hardware: PC
                OS: Mac OS X 10.1
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XWPF
          Assignee: dev@poi.apache.org
          Reporter: ekimber@contrext.com
  Target Milestone: ---

When creating new DOCX the XWPFFieldRun class does not work to create
paragraphs with CTSimpleFields.

The problem is that the field is not written out during commit. The current
unit test only tests the read path but does not test the write path, which
would fail.

I'm not sure what the right solution is (or I would have simply implemented
it).

This code works:


CTSimpleField ctField = para.getCTP().addNewFldSimple();
                ((XmlObject)ctField).newCursor()
                        .setAttributeText(
                                        QNAME_INSTR_ATT,
                                        fieldData);


So it's not a critical issue but it's definitely an annoyance in the API that
you can't create simple fields directly.

I don't have time at the moment to puzzle through this so I was hoping somebody
might have more cogent ideas about how best to address this in the API.

But my fear is that addressing this would require serious adjustment or
extension to the internals of XWPFParagraph.

Ideally I'd like something like:

XWPFSimpleField field = para.createSimpleField("PAGE");

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


[Bug 62589] Creating of simple fields when writing DOCX doesn't work in current code

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62589

--- Comment #2 from Mark Murphy <jm...@apache.org> ---
I think I can fix this rather quickly.

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


[Bug 62589] Creating of simple fields when writing DOCX doesn't work in current code

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62589

Sayi <sa...@163.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Sayi <sa...@163.com> ---
This problem seems to have been resolved in the latest version, you can use the
XWPFParagraph#createFieldRun method to create.

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


[Bug 62589] Creating of simple fields when writing DOCX doesn't work in current code

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=62589

--- Comment #1 from Mark Murphy <jm...@apache.org> ---
This works and you can stick with the schema rather than dealing with cursors.

    XWPFParagraph p;

    ...

    CTP ctP = p.getCTP();
    CTSimpleField field = ctP.addNewFldSimple();
    field.setInstr("PAGE");

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