Thank you a lot, in fact I can get the two coefficients I had empirically found by the following operations:
Code: Select all
Sub dialog1_test
Dim d, width, height, size, w1, w2, w3
d = CreateUnoDialog(DialogLibraries.Standard.dialArchivio)
width = d.Model.Width
size = CreateUnoStruct("com.sun.star.awt.Size")
size.Width = width
w1 = d.convertSizeToPixel(size, com.sun.star.util.MeasureUnit.APPFONT).Width
w2 = d.getPosSize().Width
size.Width = w2
w3 = d.convertSizeToLogic(size, com.sun.star.util.MeasureUnit.APPFONT).Width
msgbox "The width coefficient is: " & w1/w3
height = d.Model.height
size = CreateUnoStruct("com.sun.star.awt.Size")
size.height = height
w1 = d.convertSizeToPixel(size, com.sun.star.util.MeasureUnit.APPFONT).height
w2 = d.getPosSize().height
size.height = w2
w3 = d.convertSizeToLogic(size, com.sun.star.util.MeasureUnit.APPFONT).height
msgbox "The height coefficient is: " & w1/w3
End Sub
Or simply by
Code: Select all
CoeffWidth = d.getpossize.width / d.model.width
CoeffHeight = d.getpossize.height / d.model.height
Please tell me if I got this right:
- "d.Model.width" is expressed in logical units (APPFONT)
- "d.getpossize.width" is expressed in real pixels
- the conversion between these units of measurement may be performed through "convertSizeToPixel" and "convertSizeToLogic"
I haven't really figured out well how I should use the com.sun.star.util.MeasureUnit.APPFONT method (I tried to install MRI extension lots of times but I always get an error); could you please tell me how can I convert from real pixels to appfont units? I mean, if a=15 (real pixels), how can i get b (appfont units) and viceversa? The syntax of convertSizeTo... is still unclear to me, although this code worked.
Sorry about my ignorance, of course you gave me the right answer, but I can't understand it completely yet
EDIT:
Maybe I got it: this code makes the dialog as tall as the Calc window.
Code: Select all
oDial.Model.Height = frmArchivio.ConvertSizeToLogic(ThisComponent.getCurrentController.getFrame.ContainerWindow.Size, com.sun.star.util.MeasureUnit.APPFONT).Height
Before setting the topic to "SOLVED" I'll wait for your reassurance that I'm not totally wrong.