Crap, not "string" but "auto". On Wed, Aug 1, 2018 at 10:30 PM Mark Murphy <jmarkmur...@gmail.com> wrote:
> Here's how I would do it: > > public void setUnderlineColor(String color) { > CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr(); > CTUnderline underline = (pr.getU() == null) ? pr.addNewU() : > pr.getU(); > SimpleValue svColor = null; > if (color.equals("string")) { > STHexColorAuto hexColor = STHexColorAuto.Factory.newInstance(); > hexColor.set(STHexColorAuto.Enum.forString(color)); > svColor = (SimpleValue) hexColor; > } else { > STHexColorRGB rgbColor = STHexColorRGB.Factory.newInstance(); > rgbColor.setStringValue(color); > svColor = (SimpleValue) rgbColor; > } > underline.setColor(svColor); > } > > But see that code to get run properties? That is duplicated everywhere, I > would incorporate it into a new private method named > getRunProperties(boolean create) {} which would encapsulate that code and > create a new CTRPr object if necessary when create is true. So I can then > use it with getters by passing false, or setters by passing true. That can > then be refactored into the other run property methods. Similarly I would > have a private getUnderline(boolean create) {} so that I could use it in > setUnderlineColor(), or setUnderlineThemeColor(), ... > > On Wed, Aug 1, 2018 at 5:26 PM Eliot Kimber <ekim...@contrext.com> wrote: > >> I'm implementing additional set and get methods for Run properties that I >> need (or might likely need) [it's not complete over the set of all run >> properties but it adds a lot more.] >> >> The only one that has stymied me is underline color. >> >> The underline color value is an RGB color string but the OOXML API >> doesn't seem to provide for it--I suspect it's a limitation in the class >> generation from the schema. >> >> The CTUnderline API is: >> >> CTUnderline underline = (pr.getU() == null) ? pr.addNewU() : >> pr.getU(); >> Object color = underline.getColor(); >> >> That is, underline.getColor() returns Object, not something more >> specialized. >> >> In my tests, color is null (not a surprise). >> >> So my question is: how do I set the color? Should I simply be >> constructing the XML or is there a better way? >> >> Thanks, >> >> Eliot >> -- >> Eliot Kimber >> http://contrext.com >> >> >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@poi.apache.org >> For additional commands, e-mail: user-h...@poi.apache.org >> >>