Closed GoogleCodeExporter closed 9 years ago
Another argument why this is useful: the address String can contain a variable
number of lines (e.g. with or without country).
Original comment by Henno.Ve...@gmail.com
on 26 Oct 2012 at 12:50
Hi Henno,
At first, I have tried to replace '\n' with '<br :>' at
http://code.google.com/p/xdocreport/source/browse/document/fr.opensagres.xdocrep
ort.document.docx/src/main/java/fr/opensagres/xdocreport/document/docx/discovery
/DocxTemplateEngineConfiguration.java but I have commented this code because
sometimes <br /> was not setted on the well position in the document.xmll and
docx crashes.
So I think we should to use text styling transformer to manage that.
> Alternatively I could have used HTML formatting, but I found two issues with
this:
>- no formatting (font, size) is applied for lines 2 and higher, should use the
>formatting of the merge field
It's really very difficult to manage that, because preprocesisng doesn't work
with DOM but SAX (to improve performance) and it's hard to get information
about styles of mergefield (I must study how we can do that).
- special xml characters are not escaped when using html
please try with 1.0.0 (not released), I though we have fixed this problem.
>As a workaround (attached as a zip) I implemented my own
ITextStylingTransformer >which uses escapes special XML characters of the
content String and replaces newline >characters with </w:t><w:br/><w:t
xml:space="preserve">, using the knowledge that >the content will be placed
inside a <w:t> tag inside a <w:r> tag.
Yes! It's a well explanation why we must create a text styling to manage that.
>Using the more apparent documentHandler.handleLineBreak() does not work, it
gives >the same formatting issue mentioned above. (I suspect that it
unnecessarily creates >a new run (<w:r>) for the line break).
Don't hesitate to create a patch if you think it's better to manage as you
suggested.
I suggest you to modify the html text styling 1.0.0 code (and not create a new
text styling transformer) and send you a new patch. I will integrate your code.
Many thank's for your contribution.
Regards Angelo
Original comment by angelo.z...@gmail.com
on 26 Oct 2012 at 1:11
Good to see that the xml escaping with HTML formatting is solved with 1.0.0.
Will 1.0.0 then also solve the styling problem for multiple lines? If so, I
will switch to the HTML styling, otherwise I will keep the workaround in my own
code because it currently does what I need.
I think ideally, the line breaks should work without the calling code having to
do anything (register HTML styling for fields) to enable this. Currently the
calling code has to know the names of all the fields. Even if HTML styling is
still required, perhaps the calling code could become much easier if you can
set a default field styling used for all fields.
I really understand if you don't put my workaround code in xcdocreport as it is
now because it is indeed rather ugly to create a separate text style
transformer to solve this and also the "</w:t><w:br/><w:t
xml:space="preserve">" is not very clean.
Original comment by Henno.Ve...@gmail.com
on 26 Oct 2012 at 1:54
Hi Henno,
I have commited my work about \n and \t and now XDocReport manages natively
those characters (no need to develop some text styling). You can see my commit
at
http://code.google.com/p/xdocreport/source/detail?r=27e737f26ade5c716e85d577047c
f012667eb35c to see the sources (you will see that's very easy, thanks for your
code).
So your requirement will be available in the 1.0.0 (use maven to get it the
1.0.0-SNAPSHOT version or build yourself from git the xdocreport to test it).
I have commited too samples with docx/odt and velocity/freemarker with \n and
\t. You can see my commit at
http://code.google.com/p/xdocreport/source/detail?r=de9a21993b145e0cab624c1e6df1
93afc9e6c780&repo=samples
I have created 3 issues too :
1) "Manage '\n' and '\t' natively for odt and docx report." =>
http://code.google.com/p/xdocreport/issues/detail?id=181
This issue is finished.
2) "Set default text styling for fields" =>
http://code.google.com/p/xdocreport/issues/detail?id=177
3) "docx text styling reset the stlyle of the line after a br" =>
http://code.google.com/p/xdocreport/issues/detail?id=178
I close this issue.
Regards Angelo
Original comment by angelo.z...@gmail.com
on 28 Oct 2012 at 2:39
Thank you very much! It works like a charm! (I did have to update my
artifactory version so it downloads Maven snapshots from sonatype). I can now
throw away my ugly workaround code.
Original comment by Henno.Ve...@gmail.com
on 29 Oct 2012 at 11:51
Original issue reported on code.google.com by
Henno.Ve...@gmail.com
on 26 Oct 2012 at 12:48Attachments: