[Solved] Shapes within Calc, Positioning, Anchor Point

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
User avatar
Lupp
Volunteer
Posts: 3561
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: [Solved] Shapes within Calc, Positioning, Anchor Point

Post by Lupp »

The term "Anchor Point" in the above subject is misleading.
A shape inserted into a spreadsheet has an Anchor and a Position.
The Anchor can only be a single Cell or the complete Sheet ("Page" in English UI speak). You cannot anchor a shape to a row or to a column, but need to choose a specific cell of the row/column. If the row or the column of that cell is later hidden (IsVisible = False) the anchored shape will also be invisible.

The Position is a com.sun.star.awt.Point structure, and describes the position with respect to the View of the frame.
You can't set both properties independently in a way that would persist a later selection of the shape if not "appropriate". The anchor cell, if set, would automatically be adapted consistently.
In LibreOffice (V 6.3 or higher) there is also a Boolean property ResizeWithCell included for the UI with Anchor settings.

The Optimal Height feature will ignore shapes anchored to cells of the row.
You need to write user code also for this part if you want to set the row height regarding the heights of shapes. This is aggravated by the fact that the cells of a row don't know what objects are anchored to them. You need to come from the shape side to get a pair of Anchor/Shape. The only object of which a shape is automatically made a member is the DrawPage of the respective sheet.

All this is about Calc and its API, and does not depend on the scripting language.
Please tell us if you find a kind of module usable with Python which actually provides additional support concerning your task.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Post Reply