OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

howto register an add-in function written in C++ in calc
Goto page 1, 2  Next
 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
dionysio_calucci
General User
General User


Joined: 14 Oct 2004
Posts: 9

PostPosted: Sat Oct 16, 2004 3:55 am    Post subject: howto register an add-in function written in C++ in calc Reply with quote

please can someone post an example program dealing with registering an add-in function in calc? the only way i can contribute to OpenOffice is by writing financial and other add-ins in C/C++ but unfortunatelly i don't have the time to learn the UNO interface in depth... thank you in advance.
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Sat Oct 16, 2004 8:51 am    Post subject: Reply with quote

As you can see in my document, the chapter on calc add-in has only a title and nothing written. I plane to write something in the futur but don't know exacly when.
I have written on add-on and I think the subjects are similar but not the same.
When I tackle a new subject I look for an example in the Developpers Guide and try to keep the makefile and modify the code. In general all is in the makefile (it was the case with add-on).
When writing this answer, I look for an C++ add-in example in the Developpers guide but don't find any ! !!
There is a complete example in python written by DannyB in this forum. It's a good start.
To learn how to install components there is a good document in ooomacros.org
You can also start with add-on/component, there is a thread in Code Snippets under the title C++ component....
Hope that helps
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Mon Oct 18, 2004 11:25 am    Post subject: Reply with quote

I will work on add-in/C++ next week, probably starting from Danny's pyton example.
Sorry I am busy now with a problem in my local home network !
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Mon Oct 18, 2004 12:06 pm    Post subject: Reply with quote

I also have a Java example if that would be more helpful. It might be, because I'm assuming that you have to do the queryInterface business in C++ about like you do in Java.
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Tue Oct 19, 2004 11:16 am    Post subject: Reply with quote

I am interested by evrything I can read on add-in : Java, Python...
Thank you in advance
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Tue Oct 19, 2004 12:24 pm    Post subject: Reply with quote

SergeM wrote:
I am interested by evrything I can read on add-in : Java, Python...

Start here....
http://www.oooforum.org/forum/viewtopic.php?p=49922#49922


then continue reading downward.

That source code is not up to date. I have added more functions to it
http://www.oooforum.org/forum/viewtopic.php?p=51007#51007
and am still adding more.

I can update the source code posted, or send it to you. But the example linked above, even in the state it is in, probably serves as a useful example for C++.

There will be differences. In C++ the component won't be "packaged" the same way. As you can see, in Java you have a class which the service manager uses to instantiate the actual service, which is an "inner" class. I doubt that this works the same in C++. But what will be the same is that you will have to implement the com.sun.star.sheet.AddIn service, and all of its interfaces. You will have to write IDL files. So the ones I linked to above should be helpful. I also have a Calc function in Python that may also be helpful.
http://www.oooforum.org/forum/viewtopic.php?p=45369#45369
Note that both the Python add-in and Java add-in use the same IDL for the AddFive() and AddSix() functions, but have (obviously) different implementations for it.

For instance, the AddFive() function looks like this in python....
Code:
    def addFive( self, x ):
        "Add five to the argument."
        return x + 5

but looks like this in Java....
Code:
        public int addFive( /*IN*/int x ) {
            return x + 5;
        }

The AddSix() function is similar. In the above linked source code you can see how AddFive() differs from AddSix().
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Wed Oct 20, 2004 8:34 am    Post subject: Reply with quote

Thank you Danny I will have a look in few days.
I have no problem with IDL, I used it with C++ components (in Code Snippets). But I never implement the Addin service.
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Wed Oct 27, 2004 8:16 am    Post subject: Reply with quote

I have added a chapter "Add-on as humble add-in" in chapter 11 on components in my document. It's the only way I can simply do a C++ callable program from OOoCalc. calling it through Basic. I have to work more on add-on befor to takkle the Add-in chapter. It is then far to be finished.

Danny,
I have read your code only to discover that the add-in programs are too complicated for me now. The problem is I haven't any C++ example to start and I have not understood the helper philosophy... I even don't know if the registery is like the add-on and so many things. I will work again on these subject when I will have more time : probably only in summer.
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Wed Oct 27, 2004 2:17 pm    Post subject: Reply with quote

I'm not sure I understand the 2nd part about helper?

The 1st part, I would say to frist be successful at building a small component and installing it. A Calc Add-In is just a component, just not a trivial one.

The OOo registry is just a store of data types and information about how to instantiate services. When I ask for service Foo, UNO looks in the registry, realizes that Foo is registered as FooBar.jar, and uses the Java loader to load it. But tomorrow, service Foo might be stored in Foo.dll, and use the shared library loader to load it. Of course, the caller wouldn't care. But the registry tells UNO how to load the service. Also what types are available.
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Thu Oct 28, 2004 8:35 am    Post subject: Reply with quote

I have understood the goal of registery but not exacly how it works. Then I am unable to say if an add-in is installed like an add-on. I would only say probably...
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Thu Oct 28, 2004 9:25 am    Post subject: Reply with quote

The whole AddOn vs. Calc Add-In terminology is confusing. They should have picked a different term for one of them. Perhaps "plug-in", but then Glade the air-freshener people would be on their case.

The registry is just a binary file. (Group of files.) A set of code to read and write to that special binary file. The code is packaged in the form of some uno services which allow access to the registry, and also as some command line tools such as regcomp, and others, and also embedded within the higher level pkgchk tool.

You "register" types and services. The registry is just a place where uno finds this information. When I need to know that the XSomething interface has two methods that both take a single integer parameter, I can look this up in the registry. (Actually introspection does it for you.) When I need to create a service, I just ask uno for the service -- it looks in the registry to figure out what programming language to use to load the component, and then give you back the service object.

I believe that this is really all there is to the registry. When you install or remove a component using pkgchk, you are implicitly modifying the registry. pkgchk is modifying the registry on your component's behalf.
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Thu Oct 28, 2004 10:01 am    Post subject: Reply with quote

You don't think registery do more.
When I create an add-on, I see its interface in OOoBasic but not in OOocalc. Is this fact a registery consequence or not ?
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Thu Oct 28, 2004 1:51 pm    Post subject: Reply with quote

SergeM wrote:
You don't think registery do more.
When I create an add-on, I see its interface in OOoBasic but not in OOocalc. Is this fact a registery consequence or not ?


I'm not sure I understand your question?
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Fri Oct 29, 2004 7:07 am    Post subject: Reply with quote

Sometimes is my English not clear (particularly the evening).
I want to say :
You construct completely an add-on and registery it : then you see it under OOoBasic with all its methods and you can use it after instanciation.
You construct an add-in and registery it : then you see all its methods under OOoCalc (without instantiating it)
What I want to know is if the both different comportements are the fact of registery or not, to put it differently is the registery operation different in both cases ?
I only look for the simpler way to transform an add-on in add-in.
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Fri Oct 29, 2004 7:39 am    Post subject: Reply with quote

Let's clarify (and perhaps even invent) some terminology.

Add On
A menu item on the Tools menu, and an icon on the toolbar.
By modifying the Configuration sub node for AddOn, you can add new menu items and toolbar icon items to the AddOn menu or toolbar icon.

Basic programs can modify the Configuration to add some Add On items to the menu. It is not necessary to use pkgchk.

Components (see below) can also add things to the AddOn menu or toolbar when the component is installed using pkgchk.


Add In
A component (see below) which provides new Calc spreadsheet functions.
These functions show up on the Function List and Insert --> Function... dialog box. The dialog box can then fully describe your functions, their parameters, provide tooltips, etc.

Component
An UNO component, written in any supported programming language, which must be installed using the pkgchk command. (This would be "pkgchk.exe" for users afflicted with Windows.)

A component provides one or more new Services which are registered in the OOo registry. These services can be instantiated just like the factory installed services in OOo. For instance, in Basic, you can just call createUnoService( "name.DannyBrewer.magic.SomeService" ) to get an instance of the service, and then immediately call its methods or properties. Similarly, Python or Java, or Visual Basic, or any other language can use the newly installed service.

A component provides one or more services.

Service
An UNO abstraction for an Object. A service may not actually represent a single underlying object. A service may have many different interfaces which it implements. A service has properties. What methods are callable on the service are determined purely by what interfaces the service implements.


Since a Calc Add-In is just a component, which implements certian particular interfaces and services, the Calc AddIn is installed and registered in the same way as any other component. That is, a Calc AddIn is installed or removed by using pkgchk.

Making a Calc Add-In is just like making any other service. You must be a particular com.sun.star.sheet.AddIn service, and must properly implement all of its interfaces, of which there are several. But once you do this, your service magically provides new functions to the spreadsheet.
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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