RE: [libreoffice-dev] -calling a service function from BASIC macro
I was able to fix the macro to use the same service with startThr and stopThr buttons. Thanks for your help Stephan and Michael. Neeraj -Original Message- From: Rai, Neeraj [ICG-MKTS] Sent: Wednesday, February 13, 2013 1:03 PM To: 'Michael Stahl' Cc: 'Stephan Bergmann'; 'libreoffice@lists.freedesktop.org' Subject: RE: [libreoffice-dev] -calling a service function from BASIC macro Hi Michael, The links clear up some doubts in my mind. I am still having trouble with having 2 buttons to act on the same service (this is a new problem report). I created 2 buttons which calls startThr() and stopThr() on my service. The start works as expected. However, the stop call seems to create a new service and fails to stop it. I tried using a global service variable (button.macros attached), but it is giving me syntax error on line 1 expected Sub . I used the attached burger_samples.macros as sample for my macro but I might have made some obvious mistakes as this is my 1st macro. I have also found a book on macros by Andrew Pitonyak and going through it. Are there are any other resources I could use? thanks Neeraj please read this chapter: http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/C%2B%2B/C%2B%2B_Language_Binding and especially: http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/C%2B%2B/Mapping_of_Interface_Types it is generally unsound to retain a plain C++ pointer to an object after the first uno::Reference for it has been constructed. (you may retain a rtl::Reference however, which is often convenient because it can contain your implementation class directly and not just some UNO interface). startThr.macros Description: startThr.macros ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: [libreoffice-dev] -calling a service function from BASIC macro
On 12/02/13 16:31, Rai, Neeraj wrote: Hi Stephan, Is there any example of using uno calls from the forms bundled with LO ? I am not very familiar with the Reference and googling uno::Reference is not helping me either. I also couldn't find usage in sdk dir and examples dir. Would it be possible to point out a dir/file or a web link. please read this chapter: http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/C%2B%2B/C%2B%2B_Language_Binding and especially: http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/C%2B%2B/Mapping_of_Interface_Types I also wanted to understand the lifetime of uno objects . Does the CalcAddimThr_impl object live for the life of open doc ? I tried to keep my object without reference counting as there is only one instance of it and I am unfamiliar with Reference. The runThread was passed the same pointer that I assumed with live for the life of open scalc doc. But you seem to be suggesting that some other reference counted object is going out of scope making the pointer dangling. it is generally unsound to retain a plain C++ pointer to an object after the first uno::Reference for it has been constructed. (you may retain a rtl::Reference however, which is often convenient because it can contain your implementation class directly and not just some UNO interface). ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
RE: [libreoffice-dev] -calling a service function from BASIC macro
Hi Michael, The links clear up some doubts in my mind. I am still having trouble with having 2 buttons to act on the same service (this is a new problem report). I created 2 buttons which calls startThr() and stopThr() on my service. The start works as expected. However, the stop call seems to create a new service and fails to stop it. I tried using a global service variable (button.macros attached), but it is giving me syntax error on line 1 expected Sub . I used the attached burger_samples.macros as sample for my macro but I might have made some obvious mistakes as this is my 1st macro. I have also found a book on macros by Andrew Pitonyak and going through it. Are there are any other resources I could use? thanks Neeraj please read this chapter: http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/C%2B%2B/C%2B%2B_Language_Binding and especially: http://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/C%2B%2B/Mapping_of_Interface_Types it is generally unsound to retain a plain C++ pointer to an object after the first uno::Reference for it has been constructed. (you may retain a rtl::Reference however, which is often convenient because it can contain your implementation class directly and not just some UNO interface). burger_samples.macros Description: burger_samples.macros button.macros Description: button.macros ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: [libreoffice-dev] -calling a service function from BASIC macro
On 02/11/2013 06:29 PM, Rai, Neeraj wrote: The function is getting called now, however, I get a crash a bit later when sheet_ is being accessed. I also added a button and attached the macro to it for conveninece of calling. There seems to be some difference between the direct call and call via button/macro. You need to issue make run to test the crash. It invokes the uno exe with calc.uno.so The code is triggered when calc.uno.so connects and tries to access the sheet. I added print statements in the function insertIntoCellS to highlight the crash. It prints creating the header but never gets inside the function insertIntoCellS Your runThread holds a reference to the CalcAddinSpread object by plain pointer, and the refcounted object (only to be referenced via com::sun::star::uno::Reference etc.) has already been destroyed when you still access it via that now-dangling pointer. See salhelper/thread.hxx and its uses in the codebase for patterns how to use threads in LO. Stephan ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
RE: [libreoffice-dev] -calling a service function from BASIC macro
Hi Stephan, Is there any example of using uno calls from the forms bundled with LO ? I am not very familiar with the Reference and googling uno::Reference is not helping me either. I also couldn't find usage in sdk dir and examples dir. Would it be possible to point out a dir/file or a web link. I also wanted to understand the lifetime of uno objects . Does the CalcAddimThr_impl object live for the life of open doc ? I tried to keep my object without reference counting as there is only one instance of it and I am unfamiliar with Reference. The runThread was passed the same pointer that I assumed with live for the life of open scalc doc. But you seem to be suggesting that some other reference counted object is going out of scope making the pointer dangling. I'll keep reading about this. If you find time, would appreciate if you could give me any pointers to web. Thanks Neeraj ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
RE: [libreoffice-dev] -calling a service function from BASIC macro
Actually, never mind! I think I have a work around even without Reference. I made my CalcAddinThr a pointer, so it is independent of lifetime of CalcAddimThr_impl . Seems to work through button as well. I think you might have been refereeing to the object created in Basic macro that goes out of scope. Thanks again for taking time to help out on this. Neeraj ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: [libreoffice-dev] -calling a service function from BASIC macro
On 02/08/2013 04:08 PM, Rai, Neeraj wrote: So the org.openoffice.sheet.addin.CalcAddinSock service you specified implements a new UNO interface that you added (and which has a method startThr), right? Yes. Did you bundle in your extension a types.rdb that contains the information about that new interface? No. But tried to change fundamentalrc SERVICE/TYPES rows to add $ORIGIN/CalcAddinThr.rdb. scalc complained about duplicate entry. I assumed that installing the extension informs scalc about my rdb. Maybe not? I know about CORBA at conceptual level and how UNO works almost like CORBA just better. I don't understand how the unopkg and .rdb achieve that theory. Specifically, where types.rdb fits. I thought maybe unopkg add is similar to adding in types.rdb ? Helping you would probably be easiest if you gave the full source code of your extension, along with short instructions how to build it (e.g., call make from within a configured LO SDK environment). attaching the code, makefile, and readme with instructions. to extract : tar -zxvf CalcAddinThr.tgz Attached CalcAddinThr.patch solves the problem. You inadvertently registered the libCalcAddinThr.so UNO component both the old, active way (by calling regcomp, which calls your component_writeInfo) and the new, passive way (by providing a *.component file). You may want to also remove the obsolete component_writeInfo implementation from your CalcAddinThr_impl.cxx. (In order to test your code, I also needed an explicit include of unistd.h for read(2), and drop some apparently dead copy/paste stuff that caused additional compilation errors; I simply included those changes in the attached patch.) Stephan diff -rNup CalcAddinThr-ORIG/CalcAddinSpread.cxx CalcAddinThr/CalcAddinSpread.cxx --- CalcAddinThr-ORIG/CalcAddinSpread.cxx 2013-01-28 21:06:03.0 +0100 +++ CalcAddinThr/CalcAddinSpread.cxx 2013-02-11 13:44:07.084994239 +0100 @@ -2,6 +2,7 @@ #include stdio.h #include sys/time.h #include cerrno +#include unistd.h #include osl/thread.h diff -rNup CalcAddinThr-ORIG/Makefile CalcAddinThr/Makefile --- CalcAddinThr-ORIG/Makefile 2013-01-29 16:05:08.0 +0100 +++ CalcAddinThr/Makefile 2013-02-11 13:48:19.809852794 +0100 @@ -26,20 +26,7 @@ libCalcAddinThr.so: CalcAddinThr_impl.o g++ -o libCalcAddinThr.so -shared \ -L$(OO_SDK_HOME)/lib -lpthread -luno_cppuhelpergcc3 CalcAddinThr_impl.o CalcAddinSpread.o -## calc.uno.so is listed in calcuno.rdb. use make run to execute -calc.uno.so : calcuno.cxx calcCommon.h - gcc -c -fpic -fvisibility=hidden -O -I. -I $(OO_SDK_OUT)/LINUXexample.out/inc -I $(OO_SDK_OUT)/LINUXexample.out/inc/examples -I$(OO_SDK_HOME)/include -DUNX -DGCC -DLINUX -DCPPU_ENV=gcc3 -DGXX_INCLUDE_PATH=/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6 -DHAVE_GCC_VISIBILITY_FEATURE -o calcuno.o calcuno.cxx - g++ -shared '-Wl,-rpath,$ORIGIN' -L$(OO_SDK_HOME)/lib -L$(OO_SDK_URE_HOME)/lib -o calc.uno.so calcuno.o \ - -luno_cppuhelpergcc3 -luno_cppu -luno_sal - -regcomp.flag: libCalcAddinThr.so - $(OO_SDK_URE_HOME)/bin/regcomp -register -r CalcAddinThr.rdb -c libCalcAddinThr.so - touch regcomp.flag - -calccli : calccli.cpp - g++ -I /work/loc1/include/ calccli.cpp -g -o calccli -L /work/loc1/lib -lev -Wl,-rpath,/work/loc1/lib - -all: regcomp.flag calc.uno.so calccli +all: libCalcAddinThr.so install : all /usr/bin/install -p libCalcAddinThr.so CalcAddinThr.rdb ${OFFICE_PROGRAM_PATH}/ @@ -51,5 +38,5 @@ run : uno -env:URE_MORE_SERVICES=file://$(shell pwd)/calcuno.rdb -s com.sun.star.bridge.example.RemoteClientSample -- 1 clean: - rm -rf com org *.o *.urd *.so *.flag *.oxt CalcAddinThr.rdb calccli + rm -rf com org *.o *.urd *.so *.flag *.oxt CalcAddinThr.rdb ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
RE: [libreoffice-dev] -calling a service function from BASIC macro
Hi Stephan, The function is getting called now, however, I get a crash a bit later when sheet_ is being accessed. I also added a button and attached the macro to it for conveninece of calling. There seems to be some difference between the direct call and call via button/macro. You need to issue make run to test the crash. It invokes the uno exe with calc.uno.so The code is triggered when calc.uno.so connects and tries to access the sheet. I added print statements in the function insertIntoCellS to highlight the crash. It prints creating the header but never gets inside the function insertIntoCellS It doesn't happen if I call the function directly by typing =startthr() in the sheet and start calc.uno.so. I have gotten rid of _writeinfo. The new .ods file with button and new code is attached. Thanks for investing time into this. Neeraj CalcAddinThr.tgz Description: CalcAddinThr.tgz ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: [libreoffice-dev] -calling a service function from BASIC macro
On 02/08/2013 12:47 AM, Rai, Neeraj wrote: I am having trouble trying to wrap UNO function call in BASIC macro. I got the macro from the following SimpleCalcAddin example. _http://wiki.openoffice.org/wiki/SimpleCalcAddIn#Building_.26_Testing_ 1. mgr = getProcessServiceManager() 2. o = mgr.createInstance(org.openoffice.sheet.addin.CalcAddinSock) 3. o.startThr() (where my idl service returned by getServiceName() is org.openoffice.sheet.addin.CalcAddinSock and it defines a function startThr) I can call the funciton startThr() using = in the spread sheet. Also, the original example RNG is callable from macro by following the example. So the org.openoffice.sheet.addin.CalcAddinSock service you specified implements a new UNO interface that you added (and which has a method startThr), right? Did you bundle in your extension a types.rdb that contains the information about that new interface? Helping you would probably be easiest if you gave the full source code of your extension, along with short instructions how to build it (e.g., call make from within a configured LO SDK environment). Stephan ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
RE: [libreoffice-dev] -calling a service function from BASIC macro
Hi Stephan, Appreciate you taking time to debug this. So the org.openoffice.sheet.addin.CalcAddinSock service you specified implements a new UNO interface that you added (and which has a method startThr), right? Yes. Did you bundle in your extension a types.rdb that contains the information about that new interface? No. But tried to change fundamentalrc SERVICE/TYPES rows to add $ORIGIN/CalcAddinThr.rdb. scalc complained about duplicate entry. I assumed that installing the extension informs scalc about my rdb. Maybe not? I know about CORBA at conceptual level and how UNO works almost like CORBA just better. I don't understand how the unopkg and .rdb achieve that theory. Specifically, where types.rdb fits. I thought maybe unopkg add is similar to adding in types.rdb ? Helping you would probably be easiest if you gave the full source code of your extension, along with short instructions how to build it (e.g., call make from within a configured LO SDK environment). attaching the code, makefile, and readme with instructions. to extract : tar -zxvf CalcAddinThr.tgz Thanks Neeraj CalcAddinThr.tgz Description: CalcAddinThr.tgz ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
[libreoffice-dev] -calling a service function from BASIC macro
Hi, I am having trouble trying to wrap UNO function call in BASIC macro. I got the macro from the following SimpleCalcAddin example. http://wiki.openoffice.org/wiki/SimpleCalcAddIn#Building_.26_Testing 1. mgr = getProcessServiceManager() 2. o = mgr.createInstance(org.openoffice.sheet.addin.CalcAddinSock) 3. o.startThr() (where my idl service returned by getServiceName() is org.openoffice.sheet.addin.CalcAddinSock and it defines a function startThr) I can call the funciton startThr() using = in the spread sheet. Also, the original example RNG is callable from macro by following the example. One difference from the example is that I am using extension. Please advise how to call UNO functions from BASIC macro. I intend to call it on a button click. It seems like invoking macro on button click is simple (Form control to add button and assign macro using the event tab). Thanks Neeraj ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice