Page 1 of 1

Draw page size in pixel

PostPosted: Sat Sep 02, 2017 2:53 pm
by kurlukuku
Hello,

i need something like Page.width but giving the results in pixel (and not in 1/100 millimetters)

my final purpose is to get the position of a mouse click in 1/100 millimetters (and not in pixel) under open office draw

thanks for the help

Re: page size in pixel

PostPosted: Sat Sep 02, 2017 3:51 pm
by Zizi64
The Draw is a vectorgraphic software. The pixel size of the actual view of the drawing depends on the Zoom value and the pixel resolution of the screen.

Re: page size in pixel

PostPosted: Sat Sep 02, 2017 4:36 pm
by kurlukuku
Yes i figure that when my macro doing strange things after i change the zoom
I was guessing some uno service can tell how much pixel are use to display the page on the screen with the current zoom

Re: page size in pixel

PostPosted: Sat Sep 02, 2017 8:19 pm
by Zizi64
I think, the API not support such pixel unit related functions. (API = Application Programming Interface)

Re: page size in pixel

PostPosted: Sat Sep 02, 2017 10:11 pm
by JeJe
Don't know if this will help you but for Pixel/mm conversion

Code: Select all   Expand viewCollapse view

   Dim FF,ComponentW,Desktop,pixpermmmx,pixpermmmy
   Desktop = createUnoService("com.sun.star.frame.Desktop")
   FF = Desktop.getActiveFrame()
   ComponentW = FF.getComponentWindow()
   pixpermmmx =ComponentW.getInfo().PixelPerMeterX/1000
   pixpermmmy =ComponentW.getInfo().PixelPerMeterY/1000




Link for Getinfo:

https://www.openoffice.org/api/docs/common/ref/com/sun/star/awt/XDevice.html#getInfo

Re: page size in pixel

PostPosted: Sun Sep 03, 2017 10:14 am
by kurlukuku
Thanks for this i progress a lot and i almost solved my problem

with your code i write a code that give the width of the page in pixel but that only works for a zoomvalue of 100

Code: Select all   Expand viewCollapse view
Dim Doc As Object
Dim Page As Object
Doc = StarDesktop.CurrentComponent
Page = Doc.drawPages(0)
 
Dim FF,ComponentW,Desktop,pixpermmmx
Desktop = createUnoService("com.sun.star.frame.Desktop")
FF = Desktop.getActiveFrame()
ComponentW = FF.getComponentWindow()
pixpermmmx =ComponentW.getInfo().PixelPerMeterX/100000

MsgBox(Page.width*pixpermmmx)


I just need to replace Page.width*pixpermmmx by Page.width*pixpermmmx*ZoomValue/100
i find this https://wiki.openoffice.org/wiki/Docume ... gs/Zooming, but i don't figure how to use it in order to get the Zoom Value

Re: page size in pixel

PostPosted: Sun Sep 03, 2017 12:24 pm
by JeJe
try

Thiscomponent.currentController.ViewSettings.ZoomValue

Re: page size in pixel

PostPosted: Sun Sep 03, 2017 12:34 pm
by kurlukuku
Thiscomponent.currentController.ViewSettings.ZoomValue works fine for open office writter but not for draw (under draw he doesnt recognise viewsettings)

Re: page size in pixel

PostPosted: Sun Sep 03, 2017 1:39 pm
by JeJe
I tried using getViewdata to set the scroll position in Writer... if that works in draw you might be able to work out how to get the zoom. See my post at the bottom here to start you off - its as much as I know:

https://forum.openoffice.org/en/forum/v ... 20&t=84963

Re: page size in pixel

PostPosted: Sun Sep 03, 2017 2:59 pm
by John_Ha
The page size is measured in real units (inches, mm, points etc) and not in pixels.

See Where is the Display Cursor? in [Solved] Macro to measure the length of text in a .odt file for ideas.