If there ever was an answer or a comment, it was obviously lost.
<kidding>
The solution is simple and clear, of course. I give it in Basic, but it will surely love to migrate to Python.
Sub anchorAndPositionOfFormControlInaSheet(pEvent)
source = pEvent.Source
aParent = source.accessibleContext.AccessibleParent
parentEA = aParent.EXtendedAttributes
REM Get the sheet index from this pretty string:
sIndex = CInt(Split(Split(parentEA, "page-number:")(1), ";")(0)) - 1
control = source.Model
doc = control.Parent.Parent.Parent
shapeContainer = doc.Sheets(sIndex).DrawPage
uSh = shapeContainer.Count - 1
For j = 0 To uSh
j_sh = shapeContainer(j)
If EqualUnoObjects(j_sh.Control, control) Then Exit For
next j
found = (j<=uSh)
If found Then
msg = j_sh.Anchor.AbsoluteName
Else
msg = "shape hosting the control not found."
End If
MsgBox(msg)
End Sub
</kidding>
The FormControl doesn’t know about its anchor. It’s the shape hosting the control which knows.
I would suggest to distinguish copied control objects by their names in every case, but also to provide them with te needed additional information via the .Tag
property which is (fun again!) listed as “Additional information…” in the control editor. The cell to which the hosting shape is anchored shouldn’t be of much meaning.