opensagres / xdocreport

XDocReport means XML Document reporting. It's Java API to merge XML document created with MS Office (docx) or OpenOffice (odt), LibreOffice (odt) with a Java model to generate report and convert it if you need to another format (PDF, XHTML...).
https://github.com/opensagres/xdocreport
1.19k stars 369 forks source link

@w:p not working within unordered list item [docx] [freemarker] #586

Open gallyamb opened 1 year ago

gallyamb commented 1 year ago

Issue

I've tried to use custom before element https://github.com/opensagres/xdocreport/blob/dcb1377e8004ba3a30a0bd42d8c8bb013eee6d64/document/fr.opensagres.xdocreport.document/src/main/java/fr/opensagres/xdocreport/document/preprocessor/sax/TransformedBufferedDocumentContentHandler.java#L399 and custom after element https://github.com/opensagres/xdocreport/blob/dcb1377e8004ba3a30a0bd42d8c8bb013eee6d64/document/fr.opensagres.xdocreport.document/src/main/java/fr/opensagres/xdocreport/document/preprocessor/sax/TransformedBufferedDocumentContentHandler.java#L494 to enclose paragraph, that is part of unordered list, so that item in list will became conditional But, unfortunately, DocxBufferedDocument#processScriptBeforeAfter is called while DocxBufferedDocument#onEndEndElement called, i.e. when BufferedDocument#getCurrentElement already returns the parent of my paragraph, but not my paragraph itself

How to reproduce

I've created a test case xdocreport-freemarker-test-case.docx And reference document, that I want to get as a result of processing test case's template xdocreport-freemarker-reference.docx

Questions

gallyamb commented 1 year ago

In ODT processing the scripts preprocessing is done within flushCharacters method, FYI

https://github.com/opensagres/xdocreport/blob/dcb1377e8004ba3a30a0bd42d8c8bb013eee6d64/document/fr.opensagres.xdocreport.document.odt/src/main/java/fr/opensagres/xdocreport/document/odt/preprocessor/ODTBufferedDocumentContentHandler.java#L378-L385

gallyamb commented 1 year ago

Just created a test case for odt, and it works as expected xdocreport-freemarker-odt-reference.odt xdocreport-freemarker-odt-test-case.odt

gallyamb commented 1 year ago

I summon for someone with expertise in this project!

Is it ok to move scripts preprocessing in Docx into flushCharacters method just like in ODT? Or you see some pitfalls?

gallyamb commented 1 year ago

@angelozerr I see you in the few last closed issues, so I decided that you can help me too :) I'm sorry, if my assumption was wrong

Please, could you confirm or refute my thoughts in this comment? Or maybe you can tag someone who can help me?