From user-return-23086-archive-asf-public=cust-asf.ponee.io@poi.apache.org Thu Aug 2 16:32:36 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 1BDD9180629 for ; Thu, 2 Aug 2018 16:32:35 +0200 (CEST) Received: (qmail 24884 invoked by uid 500); 2 Aug 2018 14:32:33 -0000 Mailing-List: contact user-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "POI Users List" Delivered-To: mailing list user@poi.apache.org Received: (qmail 23674 invoked by uid 99); 2 Aug 2018 14:32:32 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Aug 2018 14:32:32 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 62380180453 for ; Thu, 2 Aug 2018 14:32:32 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.001 X-Spam-Level: * X-Spam-Status: No, score=1.001 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, MIME_QP_LONG_LINE=0.001, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id qJVlzDGsXBhC for ; Thu, 2 Aug 2018 14:32:31 +0000 (UTC) Received: from atl4mhob07.registeredsite.com (atl4mhob07.registeredsite.com [209.17.115.45]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 78A5E5F3CE for ; Thu, 2 Aug 2018 14:32:30 +0000 (UTC) Received: from mailpod.hostingplatform.com (atl4qobmail02pod1.registeredsite.com [10.30.71.114]) by atl4mhob07.registeredsite.com (8.14.4/8.14.4) with ESMTP id w72EWLg5011683 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 2 Aug 2018 10:32:21 -0400 Received: (qmail 9755 invoked by uid 0); 2 Aug 2018 14:32:21 -0000 X-TCPREMOTEIP: 136.62.89.1 X-Authenticated-UID: ekimber@contrext.com Received: from unknown (HELO ?192.168.1.247?) (ekimber@contrext.com@136.62.89.1) by 0 with ESMTPA; 2 Aug 2018 14:32:20 -0000 User-Agent: Microsoft-MacOutlook/10.f.0.180723 Date: Thu, 02 Aug 2018 09:32:20 -0500 Subject: Re: How to Set Underline Color? From: Eliot Kimber To: POI Users List Message-ID: <2DEF501E-CB05-4C1A-910E-3A595A1B2396@contrext.com> Thread-Topic: How to Set Underline Color? References: In-Reply-To: Mime-version: 1.0 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: quoted-printable I have implemented Mark's requests as well as set/get for underline theme c= olor and added to the pull request. Cheers, E. -- Eliot Kimber http://contrext.com =20 =EF=BB=BFOn 8/1/18, 9:30 PM, "Mark Murphy" wrote: Here's how I would do it: =20 public void setUnderlineColor(String color) { CTRPr pr =3D run.isSetRPr() ? run.getRPr() : run.addNewRPr(); CTUnderline underline =3D (pr.getU() =3D=3D null) ? pr.addNewU() : pr.getU(); SimpleValue svColor =3D null; if (color.equals("string")) { STHexColorAuto hexColor =3D STHexColorAuto.Factory.newInstanc= e(); hexColor.set(STHexColorAuto.Enum.forString(color)); svColor =3D (SimpleValue) hexColor; } else { STHexColorRGB rgbColor =3D STHexColorRGB.Factory.newInstance(= ); rgbColor.setStringValue(color); svColor =3D (SimpleValue) rgbColor; } underline.setColor(svColor); } =20 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 a= nd create a new CTRPr object if necessary when create is true. So I can th= en 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 wou= ld have a private getUnderline(boolean create) {} so that I could use it i= n setUnderlineColor(), or setUnderlineThemeColor(), ... =20 On Wed, Aug 1, 2018 at 5:26 PM Eliot Kimber wrot= e: =20 > I'm implementing additional set and get methods for Run properties th= at I > need (or might likely need) [it's not complete over the set of all ru= n > 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 do= esn't > seem to provide for it--I suspect it's a limitation in the class gene= ration > from the schema. > > The CTUnderline API is: > > CTUnderline underline =3D (pr.getU() =3D=3D null) ? pr.addNewU() : > pr.getU(); > Object color =3D 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 constru= cting > the XML or is there a better way? > > Thanks, > > Eliot > -- > Eliot Kimber > http://contrext.com > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@poi.apache.org > For additional commands, e-mail: user-help@poi.apache.org > > =20 --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@poi.apache.org For additional commands, e-mail: user-help@poi.apache.org