Find graphics that belong to a text selection

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
roland65
Posts: 32
Joined: Tue Oct 18, 2011 6:41 pm

Find graphics that belong to a text selection

Post by roland65 »

Hi,

in Writer, I know how to enumerate all the graphics contained in the DrawPage object of a document, and then select these objects and manipulate them.
I use something like this (in BASIC language0):

Code: Select all

oDrawPage = oDoc.drawPage
If oDrawPage.hasElements() Then
    ' Go through graphic elements
            For j = (oDrawPage.getCount() - 1) To 0 Step -1
                oShape = oDrawPage.getByIndex(j)
                < work on  oShape >
            Next
End If
Now, I would like to restrict these operations on a text selection. I think I can still enumerate all the graphics but I need to know which of them are contained within the selected area in order to work on these. I can get the position of the graphics but I don't know how to relate this info to the selected area...
Any help would be greatly appreciated.
Thanks,
RB
LibreOffice 7.5.x on Ubuntu
roland65
Posts: 32
Joined: Tue Oct 18, 2011 6:41 pm

Re: Find graphics that belong to a text selection

Post by roland65 »

Still no answer to this question?
Thanks for any help,
RB
LibreOffice 7.5.x on Ubuntu
musikai
Volunteer
Posts: 294
Joined: Wed Nov 11, 2015 12:19 am

Re: Find graphics that belong to a text selection

Post by musikai »

Hi RB,

in a writer document you can compare the graphics anchor position if it is within the selection range. Perhaps this might be useful:
viewtopic.php?f=20&t=80329
Win7 Pro, Lubuntu 15.10, LO 4.4.7, OO 4.1.3
Free Project: LibreOffice Songbook Architect (LOSA)
http://struckkai.blogspot.de/2015/04/li ... itect.html
roland65
Posts: 32
Joined: Tue Oct 18, 2011 6:41 pm

Re: Find graphics that belong to a text selection

Post by roland65 »

OK, thanks a lot! I'll look into the code and try to find my way...
Have a nice day,
RB
LibreOffice 7.5.x on Ubuntu
Post Reply