View | Details | Raw Unified | Return to bug 54969
Collapse All | Expand All

(-)src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java (+33 lines)
Lines 243-246 Link Here
243
243
244
244
245
    }
245
    }
246
    
247
    /**
248
     * ensure that font and color rich text attributes defined in a XSSFRichTextString
249
     * are passed to XSSFSimpleShape.
250
     *
251
     * See Bugzilla 54969.
252
     */
253
    public void testRichTextFontAndColor() {
254
    	XSSFWorkbook wb = new XSSFWorkbook();
255
        XSSFSheet sheet = wb.createSheet();
256
        XSSFDrawing drawing = sheet.createDrawingPatriarch();
257
258
        XSSFTextBox shape = drawing.createTextbox(new XSSFClientAnchor(0, 0, 0, 0, 2, 2, 3, 4));
259
        XSSFRichTextString rt = new XSSFRichTextString("Test String");
260
261
        XSSFFont font = wb.createFont();
262
        font.setColor(new XSSFColor(new Color(0, 128, 128)));
263
        font.setFontName("Arial");
264
        rt.applyFont(font);
265
266
        shape.setText(rt);
267
268
        CTTextParagraph pr = shape.getCTShape().getTxBody().getPArray(0);
269
        assertEquals(1, pr.sizeOfRArray());
270
271
        CTTextCharacterProperties rPr = pr.getRArray(0).getRPr();
272
        assertEquals("Arial", rPr.getLatin().getTypeface());
273
        assertTrue(Arrays.equals(
274
                new byte[]{0, (byte)128, (byte)128} ,
275
                rPr.getSolidFill().getSrgbClr().getVal()));
276
    	
277
    }
278
246
}
279
}
(-)src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSimpleShape.java (-2 / +2 lines)
Lines 186-193 Link Here
186
        }
186
        }
187
        if(pr.sizeOfIArray() > 0) rPr.setI(pr.getIArray(0).getVal());
187
        if(pr.sizeOfIArray() > 0) rPr.setI(pr.getIArray(0).getVal());
188
188
189
        if(pr.sizeOfFamilyArray() > 0) {
189
        if(pr.sizeOfRFontArray() > 0) {
190
            CTTextFont rFont = rPr.addNewLatin();
190
            CTTextFont rFont = rPr.isSetLatin() ? rPr.getLatin() : rPr.addNewLatin();
191
            rFont.setTypeface(pr.getRFontArray(0).getVal());
191
            rFont.setTypeface(pr.getRFontArray(0).getVal());
192
        }
192
        }
193
193

Return to bug 54969