You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Gregg Morris <gr...@gmail.com> on 2011/11/16 19:45:15 UTC
XWPF wrapper method philosophy
I'm not sure if this is the appropriate mailing list for this
question, but perhaps any lurking developers can set me straight if
necessary.
I've been using POI XWPF for a couple weeks now. Ultimately I'll be
using the POI libraries through jython, but I've been working with the
Java code as I learn my way around. My primary need for POI XWPF is
for creating fairly simple MS Word-compatible documents with somewhat
more complex tables. To do what I need to do, I've had to burrow deep
into the underlying ooxml-schema classes that are exposed by the XWPF
classes. I've mostly succeeded in creating the tables I want, but my
question is, to what extent is it appropriate for the XWPF classes to
provide higher-level support for lower-level actions?Consider this
example in my code to set the vertical alignment of a table cell:
// (assume appropriate initialization of XWPFTableCell cell)
XWPFTableCell cell = ... // get a table cell properties element
(tcPr) CTTcPr tcpr = cell.getCTTc().addNewTcPr(); // set
vertical alignment to "center" CTVerticalJc va =
tcpr.addNewVAlign(); va.setVal(STVerticalJc.CENTER);
Would it be considered appropriate for XWPFTableCell to support this
directly, with a method like this in XWPFTableCell itself?
public void setVerticalAlignment(STVerticalJc vAlign) {
CTTcPr tcpr = ctTc.addNewTcPr(); CTVerticalJc va =
tcpr.addNewVAlign(); va.setVal(vAlign); }
Note that access to the low-level STVerticalJc enum is still required.
I could create an XWPF-level enum that maps to the STVerticalJc enum,
but this goes back to my original question.
I think there are a few wrapper methods like this that would be
helpful to me, but I don't want to foist these upon the XWPF user base
if I'm going against the design philosophy. If these higher-level
wrapper methods are considered a Good Thing, I'd be happy to submit my
changes for consideration.
Thanks,Gregg
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: XWPF wrapper method philosophy
Posted by Nick Burch <ni...@alfresco.com>.
On Wed, 16 Nov 2011, Gregg Morris wrote:
> I've been using POI XWPF for a couple weeks now. Ultimately I'll be
> using the POI libraries through jython, but I've been working with the
> Java code as I learn my way around. My primary need for POI XWPF is for
> creating fairly simple MS Word-compatible documents with somewhat more
> complex tables. To do what I need to do, I've had to burrow deep into
> the underlying ooxml-schema classes that are exposed by the XWPF
> classes. I've mostly succeeded in creating the tables I want, but my
> question is, to what extent is it appropriate for the XWPF classes to
> provide higher-level support for lower-level actions?
All being well, you should never need to drop down into the CT xmlbeans
layer - everything ought to be handled by XWPF classes wrapping these in a
friendly manner.
However, being a volunteer project, not everything currently has nice code
wrapping it, so the CT beans are exposed so that people can work around
gaps. Ideally though, we want people to contribute patches to fill in gaps
in the XWPF api, so others don't need to get down that low
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org