aboutsummaryrefslogtreecommitdiffstats
path: root/src/scratchpad
diff options
context:
space:
mode:
Diffstat (limited to 'src/scratchpad')
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/record/FontEntityAtom.java34
-rw-r--r--src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java11
2 files changed, 12 insertions, 33 deletions
diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/FontEntityAtom.java b/src/scratchpad/src/org/apache/poi/hslf/record/FontEntityAtom.java
index 118fc1d3bf..4f3cdd89bc 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/record/FontEntityAtom.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/record/FontEntityAtom.java
@@ -86,38 +86,8 @@ public final class FontEntityAtom extends RecordAtom {
* @return font name
*/
public String getFontName(){
- final int maxLen = Math.min(_recdata.length,64);
- for(int i = 0; i+1 < maxLen; i+=2){
- //loop until find null-terminated end of the font name
- if(_recdata[i] == 0 && _recdata[i + 1] == 0 && !isFontNamePremature0terminated(i)) {
- return StringUtil.getFromUnicodeLE(_recdata, 0, i/2);
- }
- }
- return null;
- }
-
- /**
- * #61881: there seem to be programs out there, which write the 0-termination also
- * at the beginning of the string. Check if the next two bytes contain a valid ascii char
- * and correct the _recdata with a '?' char
- */
- private boolean isFontNamePremature0terminated(final int index) {
- if (index > 0) {
- // for now we only check the first char
- return false;
- }
-
- if (_recdata.length < index+4) {
- return false;
- }
-
- final int cp = LittleEndian.getShort(_recdata, index+2);
- if (!Character.isJavaIdentifierPart(cp)) {
- return false;
- }
-
- _recdata[index] = '?';
- return true;
+ final int maxLen = Math.min(_recdata.length,64)/2;
+ return StringUtil.getFromUnicodeLE0Terminated(_recdata, 0, maxLen);
}
/**
diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java
index a61bbaedc6..4edcb53603 100644
--- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java
+++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFShape.java
@@ -30,6 +30,7 @@ import org.apache.poi.ddf.EscherClientDataRecord;
import org.apache.poi.ddf.EscherColorRef;
import org.apache.poi.ddf.EscherColorRef.SysIndexProcedure;
import org.apache.poi.ddf.EscherColorRef.SysIndexSource;
+import org.apache.poi.ddf.EscherComplexProperty;
import org.apache.poi.ddf.EscherContainerRecord;
import org.apache.poi.ddf.EscherProperties;
import org.apache.poi.ddf.EscherProperty;
@@ -49,6 +50,7 @@ import org.apache.poi.sl.usermodel.ShapeContainer;
import org.apache.poi.sl.usermodel.ShapeType;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
+import org.apache.poi.util.StringUtil;
import org.apache.poi.util.Units;
/**
@@ -123,8 +125,15 @@ public abstract class HSLFShape implements Shape<HSLFShape,HSLFTextParagraph> {
/**
* @return name of the shape.
*/
+ @Override
public String getShapeName(){
- return getShapeType().nativeName;
+ final EscherComplexProperty ep = getEscherProperty(getEscherOptRecord(), EscherProperties.GROUPSHAPE__SHAPENAME);
+ if (ep != null) {
+ final byte[] cd = ep.getComplexData();
+ return StringUtil.getFromUnicodeLE0Terminated(cd, 0, cd.length/2);
+ } else {
+ return getShapeType().nativeName+" "+getShapeId();
+ }
}
public ShapeType getShapeType(){