Draw page size in pixel

Creating a macro - Writing a Script - Using the API

Draw page size in pixel

Postby kurlukuku » Sat Sep 02, 2017 2:53 pm

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
Open office 4.1.2
Windows 8
kurlukuku
 
Posts: 4
Joined: Sat Sep 02, 2017 1:19 pm

Re: page size in pixel

Postby Zizi64 » Sat Sep 02, 2017 3:51 pm

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.
Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.8; AOO4.1.6
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 8376
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: page size in pixel

Postby kurlukuku » Sat Sep 02, 2017 4:36 pm

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
Open office 4.1.2
Windows 8
kurlukuku
 
Posts: 4
Joined: Sat Sep 02, 2017 1:19 pm

Re: page size in pixel

Postby Zizi64 » Sat Sep 02, 2017 8:19 pm

I think, the API not support such pixel unit related functions. (API = Application Programming Interface)
Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.8; AOO4.1.6
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 8376
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: page size in pixel

Postby JeJe » Sat Sep 02, 2017 10:11 pm

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
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 590
Joined: Wed Mar 09, 2016 2:40 pm

Re: page size in pixel

Postby kurlukuku » Sun Sep 03, 2017 10:14 am

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
Open office 4.1.2
Windows 8
kurlukuku
 
Posts: 4
Joined: Sat Sep 02, 2017 1:19 pm

Re: page size in pixel

Postby JeJe » Sun Sep 03, 2017 12:24 pm

try

Thiscomponent.currentController.ViewSettings.ZoomValue
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 590
Joined: Wed Mar 09, 2016 2:40 pm

Re: page size in pixel

Postby kurlukuku » Sun Sep 03, 2017 12:34 pm

Thiscomponent.currentController.ViewSettings.ZoomValue works fine for open office writter but not for draw (under draw he doesnt recognise viewsettings)
Open office 4.1.2
Windows 8
kurlukuku
 
Posts: 4
Joined: Sat Sep 02, 2017 1:19 pm

Re: page size in pixel

Postby JeJe » Sun Sep 03, 2017 1:39 pm

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
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 590
Joined: Wed Mar 09, 2016 2:40 pm

Re: page size in pixel

Postby John_Ha » Sun Sep 03, 2017 2:59 pm

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.
AOO 4.1.6, Windows 7 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
John_Ha
Volunteer
 
Posts: 6830
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 6 guests