scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.44k stars 528 forks source link

possibility to set all visible handles of a RECTANGULAR_CALLOUT #708

Closed nnako closed 3 years ago

nnako commented 3 years ago

Hi,

within my presentations, I am frequently using RECTANGULAR_CALLOUT elements. Within the Powerpoint GUI, they are displayed showing five "handles" with which I can adjust each one of the corners plus one further "pointer" to be placed somewhere on the current slide:

pptx.enum.shapes.MSO_SHAPE.RECTANGULAR_CALLOUT

the RECTANGULAR_CALLOUT looks something like this, where A, B, C, D and E are the visible adjustable handles:

A----------B
|          |
|  <text>  |
|          |
C----------D    <-  adjustment handle for bottom right corner
 \   /
  \ /
   E      <-  handle to manually adjust where the box points to

Now, in Powerpoint I can access and adjust the four corners of the shape by using the mouse or by using the shape's settings menu. The pointing handle E I can drag with the mouse as well. But there is no setting within the shape's settings menu where I could see the current position of the shape's handle E. And within python-pptx I don't see a corresponding member, either.

Is there a way to adjust the pointing handle E of the RECTANGULAR_CALLOUT shape by using python-pptx so that I don't need to use the Powerpoint GUI?

If there is no way, yet, could somebody assist me in finding the right places within the code base in order to be able to implement and suggest a solution myself? Unfortunately, I lack any knowledge about the python-pptx system structure, yet.

Any hints?

Thanks.

scanny commented 3 years ago

All these "handles" should be available in python-pptx. Have you studied this section in the documentation?
https://python-pptx.readthedocs.io/en/latest/user/autoshapes.html#adjusting-an-autoshape

You can ask further questions after getting as far as you can with that.

This is another document that might be helpful after some detective work:
https://github.com/scanny/python-pptx/blob/master/spec/ISO-IEC-29500-1/schemas/dml-geometries/OfficeOpenXML-DrawingMLGeometries/presetShapeDefinitions.xml

This file contains the definitions for each of the "preset" shapes, and callouts are one of those. The mapping of the names is not direct, you'll have to narrow down the one you're interested in, possibly "wedgeRectCallout". But this will tell you what the adjustment points are and how they are used to draw the shape. Also it lists the connection points.

scanny commented 3 years ago

Yeah, pretty sure wedgeRectCallout corresponds to RECTANGULAR_CALLOUT. There is some "run once" code here that I used to form some spec files for mapping these and MsoShapeRectangularCallout is mapped to wedgeRectCallout in there: https://github.com/scanny/python-pptx/blob/master/spec/gen_spec/src_data/msoAutoShapeType.py

nnako commented 3 years ago

thank you for your help, @scanny. as you mentioned above, the functionality to control the shape's adjustment handles is already present and working within the code base. so, my question is solved and there would be no need to further get into the code for me, at this point. only the documentation should be updated as the description does not fit the implementation. at least not for what I saw concerning RECTANGULAR_CALLOUT shapes. I'll try to fix the documentation as soon as I found out where / how to do so.

thank you for the links to the extensive structure description files. knowledge of those gives a good anchor point for understanding the inner workings of the python-pptx universe.