Bug 50401 - EscherOpt record property of type EscherComplexProperty returns 'unknown' for getName but has a propName
Summary: EscherOpt record property of type EscherComplexProperty returns 'unknown' for...
Alias: None
Product: POI
Classification: Unclassified
Component: HSLF (show other bugs)
Version: 3.7-FINAL
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2010-12-02 10:31 UTC by grb
Modified: 2011-07-21 11:01 UTC (History)
0 users

Powerpoint file containing a shape with a .Name property (18.50 KB, application/vnd.ms-powerpoint)
2010-12-02 10:31 UTC, grb

Note You need to log in before you can comment on or make changes to this bug.
Description grb 2010-12-02 10:31:04 UTC
Created attachment 26364 [details]
Powerpoint file containing a shape with a .Name property

In some cases, it is possible to create an EscherComplexProperty of an org.apache.poi.ddf.EscherOptRecord
that returns  'unknown' for getName(), but where the EscherOptRecord.toString() method correctly returns a string containing propName: <real property name>.

As an example:  In the attached ppt file, I've used the VBA macro that follows to set the .Name property of the blue square to a string.

Using HSLF and poi (using jython), I can write:


I then see that the last property in my EscherOpt record is:

propNum: 896, propName: groupshape.shapename, complex: true, blipId: true, data: 
00: 3C, 00, 50, 00, 41, 00, 54, 00, 48, 00, 2E (etc)

(notice the groupshape.shapename)

However, when I use POI/HSLF to iterate over the container, as follows:

   if curRecord.recordName=='Opt':
       for p in props:
           print p.getClass(), p.getName()

I get:

<type 'org.apache.poi.ddf.EscherSimpleProperty'> text.wraptext
<type 'org.apache.poi.ddf.EscherSimpleProperty'> text.anchortext
<type 'org.apache.poi.ddf.EscherRGBProperty'> fill.fillcolor
<type 'org.apache.poi.ddf.EscherRGBProperty'> fill.fillbackcolor
<type 'org.apache.poi.ddf.EscherBoolProperty'> fill.nofillhittest
<type 'org.apache.poi.ddf.EscherRGBProperty'> linestyle.color
<type 'org.apache.poi.ddf.EscherBoolProperty'> linestyle.nolinedrawdash
<type 'org.apache.poi.ddf.EscherRGBProperty'> shadowstyle.color
<type 'org.apache.poi.ddf.EscherComplexProperty'> unknown

As you can see, the last one (the EscherComplexProperty) does not properly return the propName stored in the property, and the only way that I can get to this is by using the toString method and parsing the result.

This makes it hard to visit the names of all objects

VBA Macro to set name property on a shape.

Sub NameIt()
  Dim sResponse As String

  With ActiveWindow.Selection.ShapeRange(1)
    sResponse = InputBox("new name ...", "Rename Shape", .Name)
    Select Case sResponse
     ' blank names not allowed
     Case Is = ""
       Exit Sub
     ' no change?
     Case Is = .Name
       Exit Sub
     Case Else
       On Error Resume Next
       .Name = sResponse
       If Err.Number <> 0 Then
         MsgBox "Unable to rename this shape"
       End If
    End Select
  End With

End Sub
Comment 1 Yegor Kozlov 2011-07-21 11:01:19 UTC
Fixed in r1149111, junit added.

Thanks for patience,