Bug 55009 - TextBox in shapegroup with chinese, the textrun is null
Summary: TextBox in shapegroup with chinese, the textrun is null
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSLF (show other bugs)
Version: unspecified
Hardware: PC Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-23 09:38 UTC by Linfei Zhao
Modified: 2013-05-27 08:32 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Linfei Zhao 2013-05-23 09:38:25 UTC
there is two question:

1. Manually create a ShapeGroup  in slide, and the ShapeGroup contains a TextBox. If the TextBox includes chinese character in it. When extract the ppt using POI, the TextRun of TextBox is null, and the text in TextBox will also null.

2. I use POI create PPT includes a ShapeGroup, the  ShapeGroup has some TextBoxs in it. Then using POI to parse the ppt, the TextRun of TextBox in ShapeGroup is null.

Thanks very much, I really confused. 
I am eager for your reply.
Thanks in advance.
Comment 1 Linfei Zhao 2013-05-27 08:32:41 UTC
I have solved this problem. the class TextShape has some problem. Function getTextRun() is as follows:

public TextRun getTextRun(){
        if (null == this._txtrun) initTextRun();
        if (null == this._txtrun && null != this._txtbox) {
        	TextHeaderAtom    tha = null; 
        	TextBytesAtom     tba = null;
        	StyleTextPropAtom sta = null;
        	Record[] childRecords = this._txtbox.getChildRecords();
        	for (Record r : childRecords) {
        		if (r instanceof TextHeaderAtom) {
        			tha = (TextHeaderAtom) r;
				} else if (r instanceof TextBytesAtom) {
					tba = (TextBytesAtom) r;
				} else if (r instanceof StyleTextPropAtom) {
					sta = (StyleTextPropAtom) r;
				}
        	}
        	if (null != tba) {
        		this._txtrun = new TextRun(tha, tba, sta);
        	}
         }
         return _txtrun;
     }
but sometimes the text is not TextBytesAtom but TextCharsAtom. And TextRun has two construct function. in this case, we should use another construct function.
Rewrite it as:

public TextRun getTextRun() {
    	// TODO Auto-generated method stub
    	if (null == this._txtrun) initTextRun();
        if (null == this._txtrun && null != this._txtbox) {
        	TextHeaderAtom    tha = null; 
        	TextBytesAtom     tba = null;
        	StyleTextPropAtom sta = null;
        	TextCharsAtom    tca = null;
        	Record[] childRecords = this._txtbox.getChildRecords();
        	for (Record r : childRecords) {
        		if (r instanceof TextHeaderAtom) {
        			tha = (TextHeaderAtom) r;
				} else if (r instanceof TextBytesAtom) {
					tba = (TextBytesAtom) r;
				} else if (r instanceof StyleTextPropAtom) {
					sta = (StyleTextPropAtom) r;
				}else if (r instanceof TextCharsAtom) {
					tca = (TextCharsAtom) r;
				}
        	}
        	if (null != tba) {
        		this._txtrun = new TextRun(tha, tba, sta);
        	}else if (null != tca) {
        		this._txtrun = new TextRun(tha, tca, sta);
			}
         }
         return _txtrun;
    }
}