Can anyone give me, how to use getParent(), setParent(), getPosition(), while dealing with Annotations in LibreOffice Calc Macro…give some macros code sample…
Hi First Of All , Thanks to You ( Karolus ) your code is working …But I did not Author Name.
I followed your Code and added few…
Sub Annotations_get_set_Method Dim Doc As Object, sheet As Object, cell As Object, oCell As Object Dim anno As Object 'myAnnotation As Object Doc = ThisComponent : sheet = Doc.Sheets.getByIndex(15) cell = sheet.getCellByPosition(1,2) oCell = sheet.getCellByPosition(1,21) Print cell.Annotation.Parent.AbsoluteName anno = cell.Annotation sheet.Annotations.InsertNew(oCell.CellAddress, anno.String) oCell.Annotation.isVisible = true Print oCell.Annotation.getDate() Print oCell.Annotation.getAuthor() ' Here, I did not show anything and display Empty End Sub
Any idea …
- To get Author
- createEnumeration For Accessing Enumeration
you need to set the UserCredencials: →→Tools→Options→Libreoffice→User…(and change the Annotationtext …)
& 3. You need to install:
…and then you should be able to inspect the
Thanks Karolus … I am going to try…
How to use “getParent” is obvious isnt it?
“setParent(…)” seems to not work that way, but “some working sample”:
def anno_test(): doc = XSCRIPTCONTEXT.getDocument() sheet = doc.Sheets.Tabelle1 one_cell = sheet["E8"] #cell with existing Annotation other_cell = sheet["C7"] print(one_cell.Annotation.Parent.AbsoluteName) anno = one_cell.Annotation sheet.Annotations.insertNew(other_cell.CellAddress, anno.String)
as always and always again: If you want to code use awsome_objektinspectors like Mri
Date (often misformatted) and Author (if defined, shorthand) are assigned to properties of a newly created annotation, but they aren’t added to the displayed string anywhere. In addition the annotation shape supports some character formatting.
You may play with the attached example to see how Date/Author might be appended to the annotation’s string, and probably emphasized by character attributes.
(Just playing myself. I next to never use annotations in Calc. Please don’t expect me to offer more support for this topic.)
createSheetCellAnnotation.ods (14.8 KB)
Thanks… Lupp … I downloaded your “createSheetCellAnnotation.ods” sheet… i read your code… will try some scenarios…
content.xml file, the date of creation of the annotation is stored in the “correct” form. The getDate method returns the date according to the locale set.