Hyperlink to C++ Addin Function

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
saleem145
Posts: 130
Joined: Mon Jul 02, 2012 4:47 pm

Hyperlink to C++ Addin Function

Post by saleem145 »

Hello,

How do I insert a hyperlink to a C++ Addin function that takes two arguments??

Thanks,

Saleem
OpenOffice 3.4.0
Mac OS X 10.5.8
User avatar
karolus
Volunteer
Posts: 1160
Joined: Sat Jul 02, 2011 9:47 am

Re: Hyperlink to C++ Addin Function

Post by karolus »

Hallo
In 'my' ~/user/Scripts/python/setsheetcontent2.py file are the 2 Functions:

Code: Select all

def test(*args):
    params = parameter_from_string(args[0])
    print 'arg_1: {0}\narg_2: {1}'.format(*params)

def parameter_from_string( string ):
    return string.split('params=')[1].split(';')
 


from Calc executing test with :

Code: Select all

=HYPERLINK("vnd.sun.star.script:setsheetcontent2.py$test?language=Python&location=user&params=42;88") 
that print as expected into Terminal:

Code: Select all

arg_1: 42
arg_2: 88

Karolus
AOO4, Libreoffice 6.1 on Rasbian OS (on ARM)
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
saleem145
Posts: 130
Joined: Mon Jul 02, 2012 4:47 pm

Re: Hyperlink to C++ Addin Function

Post by saleem145 »

how about c++ function
OpenOffice 3.4.0
Mac OS X 10.5.8
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Hyperlink to C++ Addin Function

Post by Villeroy »

By mere definition an "addin" is meant to be a collection of additional cell functions for the Calc component. Such a function is usable in formula context, it takes arguments and it returns one number or one text value or mutiple values in array context.
I assume that you don't mean addin functions since a hyperlink can not return any value.

Most extensions add functionality by other means. Then they are called "addon".
Taking my SpecialCells extension as an example, I can call both services DialogCellFormatRanges and DialogCellContents with a service: URL:
service:name.AndreasSaeger.SpecialCells.DialogCellFormatRanges
service:name.AndreasSaeger.SpecialCells.DialogCellContents

Same with MRI:
service:mytools.Mri
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
saleem145
Posts: 130
Joined: Mon Jul 02, 2012 4:47 pm

Re: Hyperlink to C++ Addin Function

Post by saleem145 »

Karolus has answered my question but in python -- I just want the C++ equivalent to his answer -- the URL in this case is not clear to me....

I am not referring to calling C++ functions -- the function I would like to call when someone click on the hyperlink has a return type of void and takes in two arguments....it changes some static variables and changes the behavior of my addin....

Saleem
OpenOffice 3.4.0
Mac OS X 10.5.8
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Hyperlink to C++ Addin Function

Post by Villeroy »

karolus calls a Python macro which is a completely different thing.
That routine would be called like this:
vnd.sun.star.script:Library.Module.RoutineName?language=Python&location=application&arg1=blah&arg2=123
As far as I know, you can not write any macros in C++ but you can call a macro which instaciates your addon.

Hyperlink triggers macro, macro preprocesses some arguments and triggers the add-on:

Code: Select all

def RoutineName(*args):
    srv = MyOffice.createUnoService("MyAddOn.MyService")
    params = parameter_from_string(args[0])
    srv.trigger(params)
or you call your add-on directly through a service: URL
service:MyAddon.MyService?arg1=blah&arg2=123
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply