poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yegor Kozlov <ye...@dinom.ru>
Subject Re: How to know if a shape is a table
Date Wed, 20 Aug 2008 12:28:54 GMT
You can't cast because Slide.getShapes() returns the ShapeGroup objects, not Table.

Yegor

> thanks for your quick answer.
> 
> i allready tryed 
>         if(slide instanceof table) 
> it is not working
> 
> your hack is working, but i can not cast the ShapeGroup to a Table
> 
> if(isTable(shape))
>    Table t = (Table) shape;
> 
> that throws a ClassCastException
> 
> Do you have any ideas how to cast a shape into a table?
> 
> Thanks
> Thorsten
> 
> -------- Original-Nachricht --------
>> Datum: Wed, 20 Aug 2008 15:08:40 +0400
>> Von: Yegor Kozlov <yegor@dinom.ru>
>> An: POI Users List <user@poi.apache.org>
>> Betreff: Re: How to know if a shape is a table
> 
>> The code looks a bit hacky but works in my tests:
>>
>>     /**
>>       * Check whether this group of shapes is a PPT table
>>       */
>>      public static boolean isTable(ShapeGroup shape){
>>          EscherContainerRecord spContainer = shape.getSpContainer();
>>
>>          //PPT table has a special property set with recordId=0xF122
>>          UnknownEscherRecord opt = 
>> (UnknownEscherRecord)Shape.getEscherChild((EscherContainerRecord)spContainer.getChild(0),
>> (short)0xF122);
>>          if(opt != null) {
>>              EscherPropertyFactory f = new EscherPropertyFactory();
>>              List props = f.createProperties( opt.getData(), 0,
>> opt.getInstance() );
>>              EscherSimpleProperty p = (EscherSimpleProperty)props.get(0);
>>              //not sure if this heuristic "works" in 100% of cases
>>              if(p.getPropertyNumber() == 0x39F && p.getPropertyValue() ==
>> 1){
>>                  return true;
>>              }
>>          }
>>          return false;
>>      }
>>
>> Actually, Slide.getShapes() should return correct instances of shapes and
>> the "instanceof Table" approach should work.
>> This isn't yet finished, so use the hack above.
>>
>> Yegor
>>> Hi,
>>>
>>>  
>>>
>>> I'm trying to read all shape from a PPT-File and cast them into there
>>> specific type.
>>>
>>>  
>>>
>>> Can anyone tell my how to find out if there is a table in a shape or if
>> a
>>> shape is a table.
>>>
>>>  
>>>
>>> Thanks a lot
>>>
>>> Thorsten
>>>
>>>  
>>>
>>>  
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Mime
View raw message