On 07/31/2011 03:50 AM, Johnny Rosenberg wrote:
2011/7/31 Andrew Douglas Pitonyak<andrew@pitonyak.org>:
I expect that you need to set this from the sheets draw page
' Gets the Shape of a Control( e. g. to reset the size or Position of the
control
' Parameters:
' The 'oContainer' is the Document or a specific sheet of a Calc - Document
' 'CName' is the Name of the Control
Function GetControlShape(oContainer as Object,CName as String)
Dim i as integer
Dim aShape as Object
For i = 0 to oContainer.DrawPage.Count-1
aShape = oContainer.DrawPage(i)
If HasUnoInterfaces(aShape, "com.sun.star.drawing.XControlShape") then
If ashape.Control.Name = CName then
GetControlShape = aShape
exit Function
End If
End If
Next
End Function
So, how do I call it?
Sub gcs
Dim oSize
oSize = GetControlShape(ThisComponent.Sheets(0), "button1").Size
Print oSize.Height
Print oSize.Width
End Sub
In this example, I pass the sheet containing the button with the button name
to the "GetControlShape" function. I forget the unit of measure. Hmm, oh
yeas, 1" = oSize.Height / 2540
But wait, your units metric. I think life just got easier for you :-), just
set to 500 for 1/2 CM I believe.
So you mean that the size is measured in 10⁻⁵ m (1/100 000 m)? That's
kind of odd, isn't it? But on the other hand, odd doesn't necessarily
mean wrong…
So this is correct?
500 ⇨ ½ cm=5 mm (cm≠CM, by the way)
1000 ⇨ 1 cm
10 000 ⇨ 1 dm
100 000 ⇨ 1 m
I would need to look up the units, but, I believe that I stated it
correctly.
What I did not mention, however, is that if you want to change the size,
you likely need to do something like:
Dim oSize
Dim oShape
oShape = GetControlShape(ThisComponent.Sheets(0), "button1")
oSize = oShape.Size
oSize.Height=500
oShape.Size = oSize
You cannot simply use
oShape.Size.Height=500
Reason? Because the Size object is an UnoStruct, and copy semantics are
used to return a struct rather than returning a reference as occurs with
other objects. I seem to remember that there was one or two exceptions
to that, but when I was told that, the core developer could not remember
what the exception was.
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
Info: http://www.pitonyak.org/oo.php
--
Unsubscribe instructions: E-mail to users+help@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.