| View previous topic :: View next topic |
| Author |
Message |
Didier ALAIN General User


Joined: 14 Aug 2004 Posts: 17 Location: Paris, France
|
Posted: Mon Aug 23, 2004 7:43 am Post subject: A tutorial for Programming OpenOffice.org with Visual Basic |
|
|
Hello everyone,
As said in a previous topic (http://www.oooforum.org/forum/viewtopic.php?t=11439), I'm preparing a document for Visual Basic programmers. I've translated the doc this morning from french to english, but I'm not very sure with my english
The main interest of this document is to point Visual Basic specificities when programming OOo API, but a short introduction to OOo API basic concepts is mandatory. This document is a draft and in heavy progress. I would really appreciate any contribution to this doc, as I think it could be usefull for the community :
-Correctness (and quality) of english translation
-Technical aspects, of course.
Here is the TOC :
1. First steps
1.1 For the hurried ones
1.2 Installation
1.3 Short description of OOo API
2. OOo API and Visual Basic specificities
2.1 OOP (Object-Oriented Programming) !
2.2 From MS Office to OOo
2.3 From API to programming language
2.4 From API to Visual Basic
2.5 Tips for "translation"
2.6 Main issues for the Visual Basic programmer
3. Useful Links
The doc is there :
http://www.kalitech.fr/clients/doc/VB_APIOOo_en.html
Don't hesitate to PM me if you feel it is necessary. _________________ Didier ALAIN, IT consultant
KaliTech (http://www.kalitech.fr) |
|
| Back to top |
|
 |
Sireloup General User


Joined: 22 Aug 2004 Posts: 6
|
Posted: Wed Aug 25, 2004 4:57 am Post subject: Need Help |
|
|
| I've read your tutorial and I understand it is a work in progress. It will be absolutely usefull as OOO users are growing and an entire nation of VB programmers populates the world. My problem is that I can't find a way in VB to access constants like com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK. Can You help me? Thanks in advance. |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Wed Aug 25, 2004 6:17 am Post subject: |
|
|
Good luck Didier.
For COM related issues can you ask me if you need any help on that.
Christian _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
Didier ALAIN General User


Joined: 14 Aug 2004 Posts: 17 Location: Paris, France
|
Posted: Wed Aug 25, 2004 10:18 am Post subject: Re: Need Help |
|
|
| Sireloup wrote: | | I've read your tutorial and I understand it is a work in progress. It will be absolutely usefull as OOO users are growing and an entire nation of VB programmers populates the world. |
Thank you for that !
| Sireloup wrote: | | My problem is that I can't find a way in VB to access constants like com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK. Can You help me? Thanks in advance. |
Well... This part is being revised in the tuto. I will tell you as soon as it is clear in my head.
And thank you too Christian, I won't hesitate to ask you some help ! For example, could you give me the first steps for event handling via the UNO/Automation bridge ? _________________ Didier ALAIN, IT consultant
KaliTech (http://www.kalitech.fr) |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Thu Aug 26, 2004 9:04 am Post subject: |
|
|
| The Tutorial wrote: | OOo Basic has some (usefull) integrated functions or instructions, that Visual Basic doesn't have (and the opposite is true, of course ! see the VB 6 replace - also usefull - function !). Sometimes, it is difficult to know if you call an OOo Basic function or an OOo API function, but you can always verify it with the OOo Basic Online Help, in the 'other commands' section. Don't get fooled by this. Here is a non-exhaustive list :
* ConvertToUrl
* HasUnoInterfaces (although see here)
* CreateUnoStruct (an ingrated function for setOOoProp, described before)
* CreateUnoService
* CreateUnoDialog
* CreateUnoListener
* CreateUnoValue
* ThisComponent
* Dbg_Methods
* Dbg_Properties
|
Most of these functions can in fact be recreated in VB and other languages. I have Python counterparts to most of the above.
I noticed that you did provide a link to my article....
http://www.oooforum.org/forum/viewtopic.php?t=7068#26202
Using information in this article, it would be possible to create, and publish in the tutorial, a uniform set of functions that act just like their OOo Basic counterparts. This would very likely be helpful to VB users (of which I am NOT one, otherwise, I would just write them myself).
The outline of such a library would work like this.
OOo has a function GetProcessServiceManager(), which simply returns the ServiceManager. Trivial to write in VB.
OOo has a function CreateUnoService() which is trivial to write in VB, simply call GetProcessServiceManager(), then do a createInstance() on it.
If you can create a global variable in VB that is named StarDesktop, this further enhances compatibility. If you cannot do this, then please create a function named StarDesktop(). It is trivial. Simply call your CreateUnoService() function (previous paragraph) to create the com.sun.star.frame.Desktop object. Then in translation just change "StarDesktop" to "StarDesktop()", or something like that.
OOo has a function CreateUnoStruct() which is almost trivial to write in VB. Call GetProcessServicemanager(), then call Bridge_GetStruct() on that.
I already described how to create a HasUnoInteface(). It would be nice to extend it to the pural HasUnoInterfaces() function to be truly compatible.
CreateUnoDialog() is actually possible to build, but must rely on an undocumented trick. Study this for more insight.
| Code: | Sub Main
oLibrary = createUnoService( "com.sun.star.script.ApplicationScriptLibraryContainer" )
oDialog = createUnoService( "com.sun.star.script.ApplicationDialogLibraryContainer" )
' Xray.Xray oLibrary
' Xray.Xray oDialog
' MsgBox Join( oLibrary.getElementNames(), Chr(13) )
MsgBox Join( oDialog.getElementNames(), Chr(13) )
oToolkitControls = oLibrary.getByName( "ToolkitControls" )
Xray.Xray oToolkitControls
End Sub
|
Please note that the com.sun.star.script.ApplicationDialogLibraryContainer service is undocumented. But it is everything you need to implement a CreateUnoDialog() in VB.
CreateUnoListener() -- now this one may be a problem. I just don't know how you would implement this in VB. One possibility would be if there is any kind of callback mechanism in COM. Then maybe a service could be written and installed (in python or java) which makes it possible to implement a VB (or Delphi, or Visual FoxPro) version of CreateUnoListener().
CreateUnoValue() -- I don't know how to implement this either.
ThisComponent -- there is no counterpart for VB.
Dbg_Methods -- This can most certianly be implemented, but as a function Dbg_Methods(). See my article above on HasUnoInterface().
Dbg_Properties -- ditto.
If there were a standard library of VB implementation of the above functions, and if everyone would universally accept them, much as I see lots of people using my MakePropertyValue() function, then this would IMHO be a real asset to the VB programmers. It would make it much easier for VB programmers to pick up the numerous OOo Basic examples published here and elsewhere.
BTW, I would really like to see the function in VB named MakePropertyValue, just so that more OOo Basic code can be cut and pasted to VB, much as I am able to copy and paste lots of my own code from OOo Basic to Python.
Oh, the Array() function. In Python, I was able to implement a trivial function that has the exact semantics of OOo Basic's Array() function -- making code pasting even more portable. It is possible to build an Array() function in VB?
What about LBound() / UBound()? _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Thu Aug 26, 2004 12:05 pm Post subject: |
|
|
| Quote: | And thank you too Christian, I won't hesitate to ask you some help ! For example, could you give me the first steps for event handling via the UNO/Automation bridge ?
|
Wow, you're starting with the hardest.
I had my problems with this, it is poorly explained in the Dev Guide and makes use of ugly Bridge/reflection calls, which are not documented anywhere.
It might be because I couldn't use Bridge calls in Python, but that was my experience.
I would really deal with this in the end, if I were you.
Christian _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
Didier ALAIN General User


Joined: 14 Aug 2004 Posts: 17 Location: Paris, France
|
Posted: Mon Sep 06, 2004 1:03 am Post subject: |
|
|
| Cybb20 wrote: |
Wow, you're starting with the hardest.
...
I would really deal with this in the end, if I were you.
Christian |
Thank you Christian, you confirm my suspicion. I'll try this in the end, you are right.
| DannyB wrote: |
If there were a standard library of VB implementation of the above functions, and if everyone would universally accept them, much as I see lots of people using my MakePropertyValue() function, then this would IMHO be a real asset to the VB programmers.
|
Your answer is very useful and powerful, as always. I will of course follow your advice, but I'm very busy for the moment, so the progress is not very fast. Nevertheless, I studied your rich suggestion and will work on that ASAP ! You pointed out the way to make this doc really useful : thank you for that ! I quickly added one or two beta versions of these replacement functions.
To me, the todo list before version 1 :
-(exhaustive) constant declaration list for VB
-(some) VB functions, in replacement for OOoBasic ones
version 2
-Event handling
-(exhaustive) replacement VB functions _________________ Didier ALAIN, IT consultant
KaliTech (http://www.kalitech.fr) |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
|
| Back to top |
|
 |
Didier ALAIN General User


Joined: 14 Aug 2004 Posts: 17 Location: Paris, France
|
Posted: Tue Oct 05, 2004 10:28 am Post subject: |
|
|
Thank you Christian,
I've read this a long time ago, but this example is really too short to be helpful. Thanks anyway !
Didier _________________ Didier ALAIN, IT consultant
KaliTech (http://www.kalitech.fr) |
|
| Back to top |
|
 |
mpx200 Newbie

Joined: 10 Aug 2006 Posts: 4
|
Posted: Thu Aug 10, 2006 10:49 pm Post subject: .net |
|
|
| please, might you post this solution for vb.net, i'm never worked in vb6 so i can't use code above. i'm working in #develop 2.0, i need to open openoffice.org writer dokument and to write in it, any solution may be usefull |
|
| Back to top |
|
 |
deebikas General User

Joined: 27 Jun 2010 Posts: 6 Location: Hyderabad
|
Posted: Mon Jun 28, 2010 12:30 am Post subject: Disable OpenOffice copy,save,print using VB code. |
|
|
Hi,
The article http://www.kalitech.fr/clients/doc/VB_APIOOo_en.html was very useful.
I understood the basics from that article. Now, I want to know how to disable the features like copy, save, print for a particular document. I am totally not sure how to do it. I am a newbie to OO so please help. _________________ Regards,
Deebika |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|