Bug 59327

Summary: Setting text direction on a table cell has no effect
Product: POI Reporter: Alex Kapichnikov <pelymtown>
Component: XSLFAssignee: POI Developers List <dev>
Severity: normal    
Priority: P2    
Version: 3.15-dev   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: Version of XSLFTableCellclass with fixed version text direction getter/setter methods.

Description Alex Kapichnikov 2016-04-14 17:57:44 UTC
Created attachment 33764 [details]
Version of XSLFTableCellclass with fixed version text direction getter/setter methods.

Trying to set direction of a text inside a table cell by using setTextDirection() method on the cell has no effect as text direction does not change. Try the following code to reproduce the issue:

import java.awt.Rectangle;
import java.io.File;
import java.io.FileOutputStream;

import org.apache.poi.sl.usermodel.TextShape.TextDirection;
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.poi.xslf.usermodel.XSLFSlide;
import org.apache.poi.xslf.usermodel.XSLFTable;
import org.apache.poi.xslf.usermodel.XSLFTableCell;
import org.apache.poi.xslf.usermodel.XSLFTableRow;
import org.apache.poi.xslf.usermodel.XSLFTextParagraph;
import org.apache.poi.xslf.usermodel.XSLFTextRun;

public class TextDirectionTest {

	public static void main(String[] args) throws Exception {
        String outputFilePath = args[0];

        XMLSlideShow ppt = new XMLSlideShow(); 
		XSLFSlide slide = ppt.createSlide();

		XSLFTable tbl = slide.createTable();
        tbl.setAnchor(new Rectangle(50, 50, 200, 200));
		XSLFTableRow tr = tbl.addRow();

		XSLFTableCell cell = tr.addCell();
		XSLFTextParagraph p = cell.addNewTextParagraph();
        XSLFTextRun r = p.addNewTextRun();
        r.setText("Cell #1 vertical text");
		FileOutputStream fos = new FileOutputStream(new File(outputFilePath));


When the file produced by the above code is opened the direction of text is still horizontal.

The issue can also be reproduced in v3.11 (where it was originally discovered).

In order to address the problem, default implementation(s) of text direction getter/setter methods (from XSLFTextShape) need to be overridden in XSLFTableCell class as demonstrated in the attached code.
Comment 1 Andreas Beeker 2016-05-04 22:29:18 UTC
Applied/fixed with r1742338
- added test
- added support for hslf