Skip to content

Commit f25da26

Browse files
Revert 0a2debb commit changes in AbstractRenderer, fix issue in a more appropriate way, minor fixes for the sake of .net porting
1 parent 18cf856 commit f25da26

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

layout/src/main/java/com/itextpdf/layout/renderer/AbstractRenderer.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -294,19 +294,7 @@ public PdfFont getPropertyAsFont(int property) {
294294
* @return a {@link Color}
295295
*/
296296
public Color getPropertyAsColor(int property) {
297-
Object object = getProperty(property);
298-
299-
if(object == null) {
300-
return null;
301-
}
302-
303-
if(object instanceof Color) {
304-
return (Color) object;
305-
} else if (object instanceof Background) {
306-
return ((Background)object).getColor();
307-
}
308-
309-
throw new IllegalStateException("The type of property is unexpected.. property: " + property + ", class: " + object.getClass());
297+
return this.<Color>getProperty(property);
310298
}
311299

312300
/**

layout/src/main/java/com/itextpdf/layout/renderer/AccessibleAttributesApplier.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ This file is part of the iText (R) project.
5656
import com.itextpdf.kernel.pdf.tagging.PdfStructElem;
5757
import com.itextpdf.kernel.pdf.tagutils.AccessibilityProperties;
5858
import com.itextpdf.kernel.pdf.tagutils.IAccessibleElement;
59+
import com.itextpdf.layout.property.Background;
5960
import com.itextpdf.layout.property.HorizontalAlignment;
6061
import com.itextpdf.layout.property.ListNumberingType;
6162
import com.itextpdf.layout.property.Property;
@@ -154,9 +155,9 @@ public static void applyTableAttributes(AbstractRenderer renderer) {
154155
}
155156

156157
private static void applyCommonLayoutAttributes(AbstractRenderer renderer, PdfDictionary attributes) {
157-
Color backgroundColor = renderer.getPropertyAsColor(Property.BACKGROUND);
158-
if (backgroundColor != null && backgroundColor instanceof DeviceRgb) {
159-
attributes.put(PdfName.BackgroundColor, new PdfArray(backgroundColor.getColorValue()));
158+
Background background = renderer.<Background>getProperty(Property.BACKGROUND);
159+
if (background != null && background.getColor() instanceof DeviceRgb) {
160+
attributes.put(PdfName.BackgroundColor, new PdfArray(background.getColor().getColorValue()));
160161
}
161162

162163
//TODO NOTE: applying border attributes for cells is temporarily turned off on purpose. Remove this 'if' in future.

layout/src/test/java/com/itextpdf/layout/BackgroundColorTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ public static void beforeClass() {
3737
createDestinationFolder(destinationFolder);
3838
}
3939

40-
@Rule
41-
public ExpectedException thrown = ExpectedException.none();
42-
4340
@Test
4441
public void shouldAddBackgroundColorAttributeToAccessiblityWhenBackgroundColorIsSet() throws IOException, XMPException, InterruptedException {
4542
fileName = "simpleBackgroundColorTest.pdf";

0 commit comments

Comments
 (0)