Re: [libreoffice-users] Code snippet
2011/7/31 Andrew Douglas Pitonyak and...@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 Kind regards Johnny Rosenberg ジョニー・ローゼンバーグ On 07/30/2011 07:05 PM, Bill Gradwohl wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I've searched and can't figure out how to specify the height of a button at execution time via a basic macro. If Sheet1 contains a button name OK, how would I specify a button height of 0.5cm? The only examples I can find are for buttons on forms, not on a sheet itself. - -- Bill Gradwohl Roatan, Honduras -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAk40jisACgkQ7Orvev+eC8rGHQCgmq3OwAJmVey+UVF051lvj9nj agYAoIiZ3ZEl5074W6+CpTowdUxilfcl =U2Iw -END PGP SIGNATURE- -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- Unsubscribe instructions: E-mail to users+h...@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 -- Unsubscribe instructions: E-mail to users+h...@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
Re: [libreoffice-users] Code snippet
On 07/31/2011 03:50 AM, Johnny Rosenberg wrote: 2011/7/31 Andrew Douglas Pitonyakand...@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+h...@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
Re: [libreoffice-users] Code snippet
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/30/2011 10:57 PM, Andrew Douglas Pitonyak wrote: I expect that you need to set this from the sheets draw page Thank You Andrew. I have a copy of your book back in Texas. I wish I had it here on the island. I wrote most of the POS system we use in our restaurant by referencing your book. It's 9000 lines of macro code. I was up on your web site yesterday and noted that you're putting out a new edition. I tried wrapping my head around UNO several times and failed. I just don't get it. I've hit api.openoffice.org trying to make heads or tails out of what's there, but no joy. The API is an impenetrable collection of unrelated spare parts as far as I'm concerned, and I'm a professional programmer (IBM Mainframes Linux O/S utilities). I can't seem to get the right approach or frame of mind to understand the API set and UNO in particular. That's why I had to ask for help, and you came through. Thank You. - -- Bill Gradwohl Roatan, Honduras 504 9 899 2652 -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAk41nKcACgkQ7Orvev+eC8ouzgCg02jt9ON1ZahM4PoYQg83uHPj cosAninW5UjFnmRKHrlpKVqsGubBLjrB =tKaN -END PGP SIGNATURE- -- Unsubscribe instructions: E-mail to users+h...@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
Re: [libreoffice-users] Code snippet
Oh! So I'm not a moron after all. However, I downloaded AndrewMacro.pdf few days ago and found Andrew's approach more practical and easier to grasp...and I'm approaching UNO and OOo/LibreOffice from python. The Developers guide is for elitist coders. If the devs wants to attract extension development via macro scripting, they should consider making those docs more like english language. sent from mobile device -Original Message- From: Bill Gradwohl b...@ycc.com Date: Sun, 31 Jul 2011 12:19:25 To: users@global.libreoffice.org Reply-To: users@global.libreoffice.org Subject: Re: [libreoffice-users] Code snippet -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/30/2011 10:57 PM, Andrew Douglas Pitonyak wrote: I expect that you need to set this from the sheets draw page Thank You Andrew. I have a copy of your book back in Texas. I wish I had it here on the island. I wrote most of the POS system we use in our restaurant by referencing your book. It's 9000 lines of macro code. I was up on your web site yesterday and noted that you're putting out a new edition. I tried wrapping my head around UNO several times and failed. I just don't get it. I've hit api.openoffice.org trying to make heads or tails out of what's there, but no joy. The API is an impenetrable collection of unrelated spare parts as far as I'm concerned, and I'm a professional programmer (IBM Mainframes Linux O/S utilities). I can't seem to get the right approach or frame of mind to understand the API set and UNO in particular. That's why I had to ask for help, and you came through. Thank You. - -- Bill Gradwohl Roatan, Honduras 504 9 899 2652 -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAk41nKcACgkQ7Orvev+eC8ouzgCg02jt9ON1ZahM4PoYQg83uHPj cosAninW5UjFnmRKHrlpKVqsGubBLjrB =tKaN -END PGP SIGNATURE- -- Unsubscribe instructions: E-mail to users+h...@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 -- Unsubscribe instructions: E-mail to users+h...@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
Re: [libreoffice-users] Code snippet
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/31/2011 08:19 AM, Andrew Douglas Pitonyak wrote: If ashape.Control.Name = CName then Andrew FYI - I had to put an additional test in front of the above if statement as in: if not IsNull(aShape.Control) Some of the items returned do have Control=Null via the debugger. Other than that, It's working fine. - -- Bill Gradwohl Roatan, Honduras 504 9 899 2652 -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAk413n8ACgkQ7Orvev+eC8p6wACghowvArWYqnDYmNIUnRVhWMEY 4H8An2fManqw04EYz2osfMiYhsvLVs5V =2N1t -END PGP SIGNATURE- -- Unsubscribe instructions: E-mail to users+h...@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
Re: [libreoffice-users] Code snippet
On 07/31/2011 02:19 PM, Bill Gradwohl wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/30/2011 10:57 PM, Andrew Douglas Pitonyak wrote: I expect that you need to set this from the sheets draw page Thank You Andrew. I have a copy of your book back in Texas. I wish I had it here on the island. This is NOT complete, but it is updated. I am in the process of writing a new version. http://www.pitonyak.org/OOME_3_0.odt I wrote most of the POS system we use in our restaurant by referencing your book. It's 9000 lines of macro code. I was up on your web site yesterday and noted that you're putting out a new edition. I tried wrapping my head around UNO several times and failed. I just don't get it. I've hit api.openoffice.org trying to make heads or tails out of what's there, but no joy. The API is an impenetrable collection of unrelated spare parts as far as I'm concerned, and I'm a professional programmer (IBM Mainframes Linux O/S utilities). I can't seem to get the right approach or frame of mind to understand the API set and UNO in particular. Do you know about Object Oriented Programming? For obvious reasons, OOo/LO is built using objects. If you look at the code that is LO, these objects are used and manipulated. The idea behind UNO is that I can access those internal LO objects directly. The tricky part is that when you get an object that is one of those internal LO objects, it typically supports many services and interfaces. You then need to understand how those services and interfaces tell you how to use the object. I think that my head is beginning to hurt. That's why I had to ask for help, and you came through. Thank You. Your welcome! - -- Bill Gradwohl Roatan, Honduras 504 9 899 2652 -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAk41nKcACgkQ7Orvev+eC8ouzgCg02jt9ON1ZahM4PoYQg83uHPj cosAninW5UjFnmRKHrlpKVqsGubBLjrB =tKaN -END PGP SIGNATURE- -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- Unsubscribe instructions: E-mail to users+h...@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
Re: [libreoffice-users] Code snippet
On 07/31/2011 03:48 PM, Tom Davies wrote: Hi :) +1 The devs guide is not meant to be elitist but probably needs a re-write from a more normal user perspective lol. I'm sure the Documentation Team will work on it one day but it's not top priority just yet. Well, if you really understand things like UML and such, then the developers guide provides significant information. Oh! So I'm not a moron after all. However, I downloaded AndrewMacro.pdf few days ago and found Andrew's approach more practical and easier to grasp...and I'm approaching UNO and OOo/LibreOffice from python. Excellent. Glad that it helped. I tried to fire up a few Python examples using old libraries created by Danny Brewer (who used to be very active in the OOo community). Unfortunately, they failed :-( I was able to run simple Python examples, however. -- Unsubscribe instructions: E-mail to users+h...@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
Re: [libreoffice-users] Code snippet
Andrew, On Sun, 2011-07-31 at 21:49 -0400, Andrew Douglas Pitonyak wrote: On 07/31/2011 02:19 PM, Bill Gradwohl wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/30/2011 10:57 PM, Andrew Douglas Pitonyak wrote: I expect that you need to set this from the sheets draw page Thank You Andrew. I have a copy of your book back in Texas. I wish I had it here on the island. This is NOT complete, but it is updated. I am in the process of writing a new version. http://www.pitonyak.org/OOME_3_0.odt I wrote most of the POS system we use in our restaurant by referencing your book. It's 9000 lines of macro code. I was up on your web site yesterday and noted that you're putting out a new edition. I tried wrapping my head around UNO several times and failed. I just don't get it. I've hit api.openoffice.org trying to make heads or tails out of what's there, but no joy. The API is an impenetrable collection of unrelated spare parts as far as I'm concerned, and I'm a professional programmer (IBM Mainframes Linux O/S utilities). I can't seem to get the right approach or frame of mind to understand the API set and UNO in particular. Do you know about Object Oriented Programming? For obvious reasons, OOo/LO is built using objects. If you look at the code that is LO, these objects are used and manipulated. The idea behind UNO is that I can access those internal LO objects directly. The tricky part is that when you get an object that is one of those internal LO objects, it typically supports many services and interfaces. You then need to understand how those services and interfaces tell you how to use the object. I think that my head is beginning to hurt. That's why I had to ask for help, and you came through. Thank You. Your welcome! - -- Bill Gradwohl Roatan, Honduras 504 9 899 2652 -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAk41nKcACgkQ7Orvev+eC8ouzgCg02jt9ON1ZahM4PoYQg83uHPj cosAninW5UjFnmRKHrlpKVqsGubBLjrB =tKaN -END PGP SIGNATURE- -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php Your 3rd edition is very good, you seem to hit the right level and tone. -- Jay Lozier jsloz...@gmail.com -- Unsubscribe instructions: E-mail to users+h...@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
[libreoffice-users] Code snippet
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I've searched and can't figure out how to specify the height of a button at execution time via a basic macro. If Sheet1 contains a button name OK, how would I specify a button height of 0.5cm? The only examples I can find are for buttons on forms, not on a sheet itself. - -- Bill Gradwohl Roatan, Honduras -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAk40jisACgkQ7Orvev+eC8rGHQCgmq3OwAJmVey+UVF051lvj9nj agYAoIiZ3ZEl5074W6+CpTowdUxilfcl =U2Iw -END PGP SIGNATURE- -- Unsubscribe instructions: E-mail to users+h...@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
Re: [libreoffice-users] Code snippet
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. On 07/30/2011 07:05 PM, Bill Gradwohl wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I've searched and can't figure out how to specify the height of a button at execution time via a basic macro. If Sheet1 contains a button name OK, how would I specify a button height of 0.5cm? The only examples I can find are for buttons on forms, not on a sheet itself. - -- Bill Gradwohl Roatan, Honduras -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAk40jisACgkQ7Orvev+eC8rGHQCgmq3OwAJmVey+UVF051lvj9nj agYAoIiZ3ZEl5074W6+CpTowdUxilfcl =U2Iw -END PGP SIGNATURE- -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- Unsubscribe instructions: E-mail to users+h...@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