Ovpms-1460 Docx Support

I saw this one sitting in the Jira to do list - and figured I would attack it while working on the jasperreport upgrade - 

I have got a the system generating pdf's for docx files which was pretty quick, however I have run into a sticking point over userfield importing - the .doc implementation transposes for input fields easily but the userfields or mergefields are not being enumerated...I delved into the Uno library and did some digging, but I couldnt find any imformation to allow access to them.  

http://stackoverflow.com/questions/26425234/extract-user-fields-and-inpu...

I posted the above on stack to get some help but unusually I am 72 hrs out with not so much as a "badly worded question jab"

At this stage I have a new msworddocumentx object which eventually handle the files, and once we have the userfields stuff we can then support docx as templates. 

I also have a failing test constructed (and failing on userfield extraction) and a test documentx created from the existing test doc.

Finally,  Is there interest in supporting spreadsheet templates or attachments?  I would have thought not, but the implementation wouldnt take much.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Ovpms-1460 Docx Support

For .doc files, MERGEFIELDS are reported as supporting the com.sun.star.text.TextField.Database service. i.e.

 

XComponentLoader loader = //... bootstrap component loader

XComponent document = loader.loadComponentFromURL("private:stream", "_blank", 0, properties);
XTextFieldsSupplier supplier = UnoRuntime.queryInterface(XTextFieldsSupplier.class, document);
XEnumerationAccess fields = supplier.getTextFields();
XEnumeration en = fields.createEnumeration();
while (en.hasMoreElements()) {
    Object field = en.nextElement();
    XServiceInfo info = UnoRuntime.queryInterface(XServiceInfo.class, field);
    if (info != null && info.supportsService("com.sun.star.text.TextField.Database")) {
        // got a MERGEFIELD
    }
}

For .docx, are the MERGEFIELDS being reported as supporting a different service, or not listed at all?

If you don't get anywhere on SO, try https://forum.openoffice.org/en/forum/

Re: Ovpms-1460 Docx Support

Actually, if you open a .docx in OpenOffice 4.0, MERGEFIELDS aren't included, so it may not be supported.

There is a similar issue for Fill-In fields: https://issues.apache.org/ooo/show_bug.cgi?id=123826

 

 

Re: Ovpms-1460 Docx Support

Yeah it apparently was supported in 3.5 but it dissappeared and now is filed as  a bug....I will set it so they cant be used as templates for now.

 

THat being said I think eventually they will be returned as XnameAcess fields

with com.sun.star.text.FieldMaster.database similar to Odt

Regards
 
Ben 
OpenVPMS Installer and Helper 
Ph: +61423044823 
Email: info[at]charltonit.com[dot]au
Syndicate content