> Therefore I also rate it a better method to give each shape a reference to the
> original EscherContainerRecord, and extract properties only on request, saving
> memory and processing time.
>

that is what we are doing :) The new design of the HSSF drawing layer
will be pretty much like HSLF.

> It also seems that this design makes the HSSF Shapes more similar to shapes in
> other areas of POI (but I just peeked into them superficially):
>
> HSLF: org.apache.poi.hslf.model.Shape contains the following constructor:
>  protected Shape(EscherContainerRecord escherRecord, Shape parent)
>
> HWPF: org.apache.poi.hwpf.usermodel.Picture contains the following 
> constructor:
>  public Picture(EscherBlipRecord blipRecord)
>
> So there are already Shape classes in other POI components that go this way,
> and it makes sense to me.
>
> From a wider perspective, it would also seem that a unified Drawing and Shape
> package would be very valuable.
> While you can currently use shapes in hssf/xssf, hslf, hwpf (and maybe some
> more components I didn't discover), the only way to pass shapes across
> component borders (say a shape in a hssf sheet to a hslf slide) is to create a
> corresponding shape in the target document and use getter/setter methods to
> copy properties. This of course only works, if
> - the source and target document support the same shape type
> - the source and target document each provide getter and setter for all
> properties
> - you create code to handle each different shape type explicitly, because you
> must use different getters/setters for each shape type
>
> it would give users great power to do instead something like:
>
>  HSSFSheet excelSheet = ...
>  HWPFDocument wordDoc = ...
>  Drawing excelDrawing = excelSheet.getDrawing();
>  for (Shape s : excelDrawing.getShapes()) {
>     wordDoc.addDrawing().addShape(s);  // implicit cloning of shape assumed
>  }
>
> or
>
>  Shape s = userMethodToConstructAVeryComplexShape();
>  // note that at shape creation time, it is unknown if the shape is
>  // going to be added to an excel sheet or a word document
>  HSSFSheet excelSheet = ...
>  excelSheet.getDrawing().addShape(s);
>  HWPFDocument wordDoc = ...
>  wordDoc.addDrawing().addShape(s);
>
>


A unified drawing API is a long-term goal. Perhaps, for a start we can
merge implementations for HSSF and HSLF.
HWPF is much less mature but it can be extended in the same way.

Yegor

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to