Bug 59327 - Setting text direction on a table cell has no effect
Summary: Setting text direction on a table cell has no effect
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: XSLF (show other bugs)
Version: 3.15-dev
Hardware: All All
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-14 17:57 UTC by Alex Kapichnikov
Modified: 2016-05-04 22:29 UTC (History)
0 users



Attachments
Version of XSLFTableCellclass with fixed version text direction getter/setter methods. (15.56 KB, patch)
2016-04-14 17:57 UTC, Alex Kapichnikov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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");
        
        cell.setTextDirection(TextDirection.VERTICAL);
	    
		FileOutputStream fos = new FileOutputStream(new File(outputFilePath));
		ppt.write(fos);
		ppt.close();
		fos.close();
	}

}

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