Bug 50401 - EscherOpt record property of type EscherComplexProperty returns 'unknown' for getName but has a propName
EscherOpt record property of type EscherComplexProperty returns 'unknown' for...
Status: RESOLVED FIXED
Product: POI
Classification: Unclassified
Component: HSLF
3.7-FINAL
PC Linux
: P2 normal (vote)
: ---
Assigned To: POI Developers List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2010-12-02 10:31 UTC by grb
Modified: 2011-07-21 11:01 UTC (History)
0 users



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

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:

ss=SlideShow(HSLFSlideShow('x.ppt'))
ss.slides[0].shapes[-1].getSpContainer()

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:

itt=ss.slides[0].shapes[-1].getSpContainer().getIterator()
while(itt.hasNext()):
   curRecord=itt.next()
   if curRecord.recordName=='Opt':
       props=curRecord.getEscherProperties()
       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,
Yegor