How to get text area rectangle from shape type, position, size and adjustment values?

Miklos Vajna vmiklos at
Wed Jul 27 09:18:24 UTC 2022

Hi Regina,

On Sun, Jul 24, 2022 at 11:59:28PM +0200, Regina Henschel <rb.henschel at> wrote:
> I know that the calculation of moTextOffFoo values in transform2dcontext is
> correct in principle. But I am very unhappy with calculating the position
> and size of the required text area rectangle by hand using the preset
> geometry. I have now done this for the shape types that I know are in the
> preset SmartArts. But the user can also exchange these shapes with others in
> the UI of MS Office. So the calculation of the text area rectangle would
> have to be done for all preset shapes. That's why I'm looking for another
> way.

Briefly reading presetShapeDefinitions.xml from the OOXML spec, the
calculation of the text rectangle seems to be part of the preset, so
it's not something you can calculate in general.

> At that point I have the type of the shape and know position, size and
> adjustment values. If I had a ready CustomShape, I could get the needed text
> area rectangle with the method getTextBounds(). But in
> transform2dcontext.cxx there is no CustomShape. Or do I miss something?
> Is there any way to make such a shape temporarily so that you can use
> getTextBounds()? Or maybe someone has another idea how to get the text area
> rectangle from type, position, size and adjustment values?

Other preset data is generated from the spec, the generated result is at
oox/source/drawingml/customshapes/oox-drawingml-cs-presets. Would it be
possible to include the text rectangle information in that file as well?

Failing that, if we have this information in svx/ for custom shape
instances, then seprating this functionality into a function that you
can call from oox/ sounds reasonable. I just fear that OOXML has much
more preset types compared to the old binary formats, and perhaps svx/
preset data represents what was the feature set of binary formats.



More information about the LibreOffice mailing list