Hi All,
I want to create some sort of file viewer, pdf and graphical formats. I tried it with the UnoControlImageControl and I encountered some problems.
Through the ImageURL property I can display a graphic file, but not pdf. Further I have only two (three) sizing options: original size (often only displaying the centre of the image) or resize to fit (either isotropic or anisotropic.
draw and writer know pdf format.
My guess is that to display a pdf and also to get more sizing/scrolling options by way of a spinbox and scrollbars I have to create and fill the Graphic property myself and manipulate the content of that property.
Could anybody point me to more info on how to address this?
I program in Python and mostly work with Libreoffice, but anything working in Openoffice will work in Libreoffice.
Hika
UnoControlImageControl
UnoControlImageControl
openoffice 4.1.2/4.1.4 and libreoffice 5.4.4.2/5.4.5.1 both on Gentoo and on Windows
Re: UnoControlImageControl
Ok, I guess I need to be more clear as to what mean.
How do I read an image or pdf file in and convert it to a format usable by the Graphic property?
If I have that I want to put a virtual rectangle over it the size of the control and cut out that part to be displayed.
I want to manipulate the size and position of that rectangle through a spinbox and scrollbars.
The second and third part I can do mostly in python and I do not see any real problem there.
The part I mostly need pointers to is the first part. How to retrieve and convert the file into a format usable by the Graphic property. I have never before used that part of uno. Also examples where something similar as done, could help. Preferably in python uno, but even basic or java, although it would take me more time to decipher, could help. Anything on how to manipulate graphics in uno.
How do I read an image or pdf file in and convert it to a format usable by the Graphic property?
If I have that I want to put a virtual rectangle over it the size of the control and cut out that part to be displayed.
I want to manipulate the size and position of that rectangle through a spinbox and scrollbars.
The second and third part I can do mostly in python and I do not see any real problem there.
The part I mostly need pointers to is the first part. How to retrieve and convert the file into a format usable by the Graphic property. I have never before used that part of uno. Also examples where something similar as done, could help. Preferably in python uno, but even basic or java, although it would take me more time to decipher, could help. Anything on how to manipulate graphics in uno.
openoffice 4.1.2/4.1.4 and libreoffice 5.4.4.2/5.4.5.1 both on Gentoo and on Windows
Re: UnoControlImageControl
Hi,
the below code assumes that you have created a Dialog named "DialogImage", which contains an ImageControl names "ImageControl1"
Tested on LO 24.2, the AOO version might differ a bit
Good luck,
ms777
the below code assumes that you have created a Dialog named "DialogImage", which contains an ImageControl names "ImageControl1"
Tested on LO 24.2, the AOO version might differ a bit
Good luck,
ms777
Code: Select all
Sub Main
dialog = CreateUnoDIalog(DialogLibraries.Standard.DialogImage)
oImageControl = dialog.getControl("ImageControl1")
oProvider = createUnoService("com.sun.star.graphic.GraphicProvider")
Dim oProps(0) as new com.sun.star.beans.PropertyValue
oProps(0).Name = "URL"
oProps(0).Value = "file:///C:/users/martin/Downloads/your_file.JPG"
oImageControl.Model.Graphic = oProvider.queryGraphic(oProps())
dialog.execute()
oProps(0).Value = "file:///C:/users/martin/Downloads/your_file.PDF"
oImageControl.Model.Graphic = oProvider.queryGraphic(oProps())
dialog.execute()
End SubRe: UnoControlImageControl
Interesting, but as far as I can determine this is a more detailed way to just set the ImageURL property.
And it still won't load my pdf files. queryGraphic returns void.
And it still won't load my pdf files. queryGraphic returns void.
openoffice 4.1.2/4.1.4 and libreoffice 5.4.4.2/5.4.5.1 both on Gentoo and on Windows
Re: UnoControlImageControl
Correction. The Libreoffice version on my development system is not up to date. Checking on another system with a newer version, it does open pdf files.
So now I am going to see if I can manipulate the image. If the result is interesting I'll share it here.
So now I am going to see if I can manipulate the image. If the result is interesting I'll share it here.
openoffice 4.1.2/4.1.4 and libreoffice 5.4.4.2/5.4.5.1 both on Gentoo and on Windows
Re: UnoControlImageControl
A pdf isn't an image file - the image control is never going to load it. A thumbnail preview perhaps.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: UnoControlImageControl
Sorry to disappoint your sturdy preconception. It does load in LO7.
Whether it falls under any definition of being an image is irrelevant. It is only relevant whether there is a import filter to convert it to DIB, the format used by the control. My guess is that the format is a mixture of vector based graphics for text exported through an export filter and bitmap graphics for the rest. And possibly being all bitmap when created by scanning. But I have not examined the format in depth.
Friendly greetings,
Hika
openoffice 4.1.2/4.1.4 and libreoffice 5.4.4.2/5.4.5.1 both on Gentoo and on Windows
Re: UnoControlImageControl
You can open it in draw in LO, export it to a picture format, and load that to an image control.
You can create a draw document as a child window of your dialog, and remove all the decoration such as toolbars etc.
You can create a draw document as a child window of your dialog, and remove all the decoration such as toolbars etc.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: UnoControlImageControl
That options has occurred to me, but since in newer versions of LO pdf displays in the UnoControlImageControl, I'll first explore that path. It will be less top-heavy, gives me more layout freedom and the others who will use the viewer all have the latest version of LO. Moving a view window over the pdf at 100% size should be attainable.
I have evolved the dialogs to full modeless forms that are fully scalable. It's not yet fully alpha state, but once I get there I'll publish it.
openoffice 4.1.2/4.1.4 and libreoffice 5.4.4.2/5.4.5.1 both on Gentoo and on Windows