From bee666439edfbe8752b1dffb57805922538d19df Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Fri, 21 Apr 2006 14:05:42 +0000 Subject: [PATCH] Fix for bug 39374 - handle unicode text runs git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@395888 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hslf/model/TextBox.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java b/src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java index 5584ab1bef..de1d81c854 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java +++ b/src/scratchpad/src/org/apache/poi/hslf/model/TextBox.java @@ -25,6 +25,7 @@ import java.awt.*; import java.awt.font.FontRenderContext; import java.awt.font.TextLayout; import java.io.IOException; +import java.util.Vector; /** * Represents a TextFrame shape in PowerPoint. @@ -86,7 +87,7 @@ public class TextBox extends SimpleShape { /** * Create a TextBox object and initialize it from the supplied Record container. - * + * * @param escherRecord EscherSpContainer container which holds information about this shape * @param parent the parent of the shape */ @@ -95,18 +96,17 @@ public class TextBox extends SimpleShape { EscherTextboxRecord textbox = (EscherTextboxRecord)Shape.getEscherChild(_escherContainer, EscherTextboxRecord.RECORD_ID); _txtbox = new EscherTextboxWrapper(textbox); - - TextHeaderAtom tha = null; - TextBytesAtom tba = null; - StyleTextPropAtom sta = null; - Record[] child = _txtbox.getChildRecords(); - for (int i = 0; i < child.length; i++) { - if (child[i] instanceof TextHeaderAtom) tha = (TextHeaderAtom)child[i]; - else if (child[i] instanceof TextBytesAtom) tba = (TextBytesAtom)child[i]; - else if (child[i] instanceof StyleTextPropAtom) sta = (StyleTextPropAtom)child[i]; + + // Find our TextRun + Vector v = new Vector(); + Sheet.findTextRuns(_txtbox.getChildRecords(), v); + + // We should just have one + if(v.size() == 1) { + _txtrun = (TextRun)v.get(0); + } else { + throw new IllegalStateException("A TextBox should have one TextRun's worth of records in it, found " + v.size()); } - - _txtrun = new TextRun(tha,tba,sta); } /** @@ -157,6 +157,7 @@ public class TextBox extends SimpleShape { _txtbox = new EscherTextboxWrapper(); TextHeaderAtom tha = new TextHeaderAtom(); + tha.setParentRecord(_txtbox); // TextHeaderAtom is parent aware _txtbox.appendChildRecord(tha); TextBytesAtom tba = new TextBytesAtom(); -- 2.39.5