[GitHub] [poi] gffloodg commented on a diff in pull request #409: Textruns not honouring highlight
gffloodg commented on code in PR #409: URL: https://github.com/apache/poi/pull/409#discussion_r1058339320 ## poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java: ## @@ -158,6 +162,78 @@ private static void fetchFontColor(CTTextCharacterProperties props, Consumer fetchHighlightColor(props, val, shape, hasPlaceholder)); +} + + +private static void fetchHighlightColor(CTTextCharacterProperties props, Consumer val, XSLFShape shape, boolean hasPlaceholder) { +if (props == null) { +return; +} + +final CTColor col = props.getHighlight(); +if (col == null) { +return; +} + +final CTSRgbColor rgbCol = col.getSrgbClr(); +final byte[] cols = rgbCol.getVal(); +final SolidPaint paint = DrawPaint.createSolidPaint(new Color(0xFF & cols[0], 0xFF & cols[1], 0xFF & cols[2])); +val.accept(paint); +} + +/** + * Sets the font highlight (background) color for this text run - convenience function + * + * @param color The highlight (background) color to set. + * @since POI 5.2.4 + */ +@Override +public void setHighlightColor(final Color color) { +setHighlightColor(DrawPaint.createSolidPaint(color)); +} + +/** + * Set the highlight (background) color for this text run. + * + * @param color The highlight (background) color to set. + * + * @see org.apache.poi.sl.draw.DrawPaint#createSolidPaint(Color) + * @since POI 5.2.4 + */ +@Override +public void setHighlightColor(final PaintStyle color) { +if (!(color instanceof SolidPaint)) { +LOG.atWarn().log("Currently only SolidPaint is supported!"); +return; Review Comment: Updated and added tests -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For additional commands, e-mail: dev-h...@poi.apache.org
[GitHub] [poi] gffloodg commented on a diff in pull request #409: Textruns not honouring highlight
gffloodg commented on code in PR #409: URL: https://github.com/apache/poi/pull/409#discussion_r1058339152 ## poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java: ## @@ -158,6 +162,78 @@ private static void fetchFontColor(CTTextCharacterProperties props, Consumer fetchHighlightColor(props, val, shape, hasPlaceholder)); Review Comment: done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For additional commands, e-mail: dev-h...@poi.apache.org
[GitHub] [poi] gffloodg commented on a diff in pull request #409: Textruns not honouring highlight
gffloodg commented on code in PR #409: URL: https://github.com/apache/poi/pull/409#discussion_r1057764538 ## poi/src/main/java/org/apache/poi/sl/usermodel/TextRun.java: ## @@ -79,6 +80,37 @@ enum FieldType { void setFontColor(PaintStyle color); +/** + * Returns the font highlight (background) color for this text run. + * This returns a {@link SolidPaint}, or null if no highlight is set. Review Comment: Code updated, ready for review -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For additional commands, e-mail: dev-h...@poi.apache.org
[GitHub] [poi] gffloodg commented on a diff in pull request #409: Textruns not honouring highlight
gffloodg commented on code in PR #409: URL: https://github.com/apache/poi/pull/409#discussion_r1056812245 ## poi/src/main/java/org/apache/poi/sl/usermodel/TextRun.java: ## @@ -79,6 +80,37 @@ enum FieldType { void setFontColor(PaintStyle color); +/** + * Returns the font highlight (background) color for this text run. + * This returns a {@link SolidPaint}, or null if no highlight is set. Review Comment: Ok sure, let me take a look and update. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org - To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org For additional commands, e-mail: dev-h...@poi.apache.org
[GitHub] [poi] gffloodg commented on a diff in pull request #409: Textruns not honouring highlight
gffloodg commented on code in PR #409: URL: https://github.com/apache/poi/pull/409#discussion_r1056419343 ## poi-scratchpad/src/main/java/org/apache/poi/hslf/usermodel/HSLFTextRun.java: ## @@ -440,6 +440,23 @@ public void setFontColor(PaintStyle color) { setFontColor(rgb); } + +@Override +public PaintStyle getHighlightColor() { +return null; +} + +@Override +public void setHighlightColor(final Color color) { Review Comment: I agree, but the common rendering in DrawTextParagraph does not have access to the XSLF* classes, so cannot be cast - I chose this as a tradeoff. If you have a better suggestion then Im happy to adjust as needed. ## poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java: ## @@ -157,6 +160,52 @@ private static void fetchFontColor(CTTextCharacterProperties props, Consumer