RE: [libreoffice-dev] - questions about calc extension
Hi Michael, That's loads of good info. Looking at your link below and browsing around, I realised what Stephen meant when he used "EasyHacks" in one of the replies. For now I'll stick with the 3.6.4.3 and refer to release notes as I upgrade to newer versions. Thanks Neeraj -Original Message- From: Michael Stahl [mailto:mst...@redhat.com] Sent: Thursday, January 10, 2013 11:59 AM To: Rai, Neeraj [ICG-MKTS] Cc: 'libreoffice@lists.freedesktop.org' Subject: Re: [libreoffice-dev] - questions about calc extension On 10/01/13 16:42, Rai, Neeraj wrote: > Hi Stephan, > > I am unable to find XDesktop2. Your sample below looks really simple > and right way to go. I am working with release version 3.6.4.3 - > built it from tar files. XDesktop2 was only added a month ago, so it's only in 4.0. of course when using the newest features it's always a problem that it doesn't allow deploying your extension or whatever on older versions then... > I don't mind upgrading to latest tip, but I had trouble building the > git checkout version. Being fairly new to this large and > comprehensive product, I decided to take the easy way to begin. you can also download 4.0 beta releases, actually there should be a RC1 now even; i would expect those also have the SDK available. > I would also be curious to know how to find out about such api - > unfortunately, right now I am reading only specific emails on dev > group and unable to follow conversations on other topics. Is reading > docs the best way ? Is it possible to find some sample code ? good question... currently the only real info for developers who don't follow the git commits, which is probably no extension or macro developer does, is the 4.0 release notes, which has a section on API Changes: https://wiki.documentfoundation.org/ReleaseNotes/4.0#API_Changes but that doesn't talk much about what is added, mostly it's about what is changed or removed. of course you can also search in the API reference (or the IDL files) for "since" tags with a particular version. the OOo project had a "interface-announce" mailing list, which was used both for API changes and additions, and for internal implementation interface changes; i wonder how many extension developers actually read that list in its time. ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
RE: [libreoffice-dev] - questions about calc extension
Hi Kohei, Using unlockController/lock brought down the time from 12sec to 3sec. Using DataArray brought it down to 14ms! Thanks for the tips. Great thing about starting with bad code is that I get to feel happy when it improves :-) Hi Michael, Who would have thought it was a script :-) Maybe 0 bytes callgrind should have given me a hint. I am running callgrind now. Although, I don't need to based on above numbers, I am sure I'll write the next code as badly and will need it soon. I never said in the email that I was running the wrapper but you figured it out anyway. Thanks for catching it. You guys are great. Neeraj -Original Message- From: Michael Meeks [mailto:michael.me...@suse.com] Sent: Thursday, January 10, 2013 11:34 AM To: Rai, Neeraj [ICG-MKTS] Cc: 'libreoffice@lists.freedesktop.org'; Kohei Yoshida Subject: Re: [libreoffice-dev] - questions about calc extension > > What's your hunch about how long it should take to update 60K cells with > > {getCellByPosition(ii,jj) and setValue() } ? It should be ~instant - sub-second anyhow; it's an analog of loading values from ODS. Kohei's suggestions are great: > On Thu, 2013-01-10 at 10:59 -0500, Kohei Yoshida wrote: > 2) Try lockControllers() and unlockControllers() to disable/enable > repainting while updating cell values. The example of these methods > should be in my xcalc.cxx file I referenced earlier. You'd need to run callgrind like this: export OOO_DISABLE_RECOVERY=1 valgrind --tool=callgrind --simulate-cache=yes --dump-instr=yes ./soffice.bin ie. on the soffice.bin not the wrapper script ;-) HTH, Michael. -- michael.me...@suse.com <><, Pseudo Engineer, itinerant idiot ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: [libreoffice-dev] - questions about calc extension
On 10/01/13 16:42, Rai, Neeraj wrote: > Hi Stephan, > > I am unable to find XDesktop2. Your sample below looks really simple > and right way to go. I am working with release version 3.6.4.3 - > built it from tar files. XDesktop2 was only added a month ago, so it's only in 4.0. of course when using the newest features it's always a problem that it doesn't allow deploying your extension or whatever on older versions then... > I don't mind upgrading to latest tip, but I had trouble building the > git checkout version. Being fairly new to this large and > comprehensive product, I decided to take the easy way to begin. you can also download 4.0 beta releases, actually there should be a RC1 now even; i would expect those also have the SDK available. > I would also be curious to know how to find out about such api - > unfortunately, right now I am reading only specific emails on dev > group and unable to follow conversations on other topics. Is reading > docs the best way ? Is it possible to find some sample code ? good question... currently the only real info for developers who don't follow the git commits, which is probably no extension or macro developer does, is the 4.0 release notes, which has a section on API Changes: https://wiki.documentfoundation.org/ReleaseNotes/4.0#API_Changes but that doesn't talk much about what is added, mostly it's about what is changed or removed. of course you can also search in the API reference (or the IDL files) for "since" tags with a particular version. the OOo project had a "interface-announce" mailing list, which was used both for API changes and additions, and for internal implementation interface changes; i wonder how many extension developers actually read that list in its time. ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: [libreoffice-dev] - questions about calc extension
> > What's your hunch about how long it should take to update 60K cells with > > {getCellByPosition(ii,jj) and setValue() } ? It should be ~instant - sub-second anyhow; it's an analog of loading values from ODS. Kohei's suggestions are great: > On Thu, 2013-01-10 at 10:59 -0500, Kohei Yoshida wrote: > 2) Try lockControllers() and unlockControllers() to disable/enable > repainting while updating cell values. The example of these methods > should be in my xcalc.cxx file I referenced earlier. You'd need to run callgrind like this: export OOO_DISABLE_RECOVERY=1 valgrind --tool=callgrind --simulate-cache=yes --dump-instr=yes ./soffice.bin ie. on the soffice.bin not the wrapper script ;-) HTH, Michael. -- michael.me...@suse.com <><, Pseudo Engineer, itinerant idiot ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: [libreoffice-dev] - questions about calc extension
On 01/10/2013 10:50 AM, Rai, Neeraj wrote: Hi Michael, Appreciate your feedback. I ran callgrind but no output on screen and 0 bytes files generated. I can run it on non-LO exe. I'll compile LO with --enable-debug and see if situation improves. Please advise if other steps might be needed. What's your hunch about how long it should take to update 60K cells with {getCellByPosition(ii,jj) and setValue() } ? Two things you might try. 1) Try getDataArray() and setDataArray() to update multiple contiguous cells. Doing it this way is much much faster than updating one cell at a time. These methods are available for cell range object. 2) Try lockControllers() and unlockControllers() to disable/enable repainting while updating cell values. The example of these methods should be in my xcalc.cxx file I referenced earlier. HTH, Kohei -- Kohei Yoshida, LibreOffice hacker, Calc ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
RE: [libreoffice-dev] - questions about calc extension
Hi Michael, Appreciate your feedback. I ran callgrind but no output on screen and 0 bytes files generated. I can run it on non-LO exe. I'll compile LO with --enable-debug and see if situation improves. Please advise if other steps might be needed. What's your hunch about how long it should take to update 60K cells with {getCellByPosition(ii,jj) and setValue() } ? Moving from interprocess bridge speeded it up for me and I might have given up on further speed-up too quickly. I can certainly use further speedup. Thanks Neeraj -Original Message- From: Michael Meeks [mailto:michael.me...@suse.com] Sent: Thursday, January 10, 2013 4:45 AM To: Rai, Neeraj [ICG-MKTS] Cc: 'libreoffice@lists.freedesktop.org' Subject: RE: [libreoffice-dev] - questions about calc extension On Wed, 2013-01-09 at 23:18 +, Rai, Neeraj wrote: > I looked a little more into your code and copied the getactiveSheet function. > Now it takes 12s. I am happy. > Sorry for the spam - you have good code sitting there. 12s sounds like a long time to me ;-> If you can run your macro under callgrind: export OOO_DISABLE_RECOVERY=1 valgrind --tool=callgrind --simulate-cache=yes \ --dump-instr=yes ./soffice.bin -writer --splash-pipe=0 (needs write-permission to the installed libreoffice directory to drop it's callgrind.12345.txt file) Then perhaps kcachegrind will show you something interesting for your use-case. HTH, Michael. -- michael.me...@suse.com <><, Pseudo Engineer, itinerant idiot ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
RE: [libreoffice-dev] - questions about calc extension
Hi Stephan, I am unable to find XDesktop2. Your sample below looks really simple and right way to go. I am working with release version 3.6.4.3 - built it from tar files. I don't mind upgrading to latest tip, but I had trouble building the git checkout version. Being fairly new to this large and comprehensive product, I decided to take the easy way to begin. I would also be curious to know how to find out about such api - unfortunately, right now I am reading only specific emails on dev group and unable to follow conversations on other topics. Is reading docs the best way ? Is it possible to find some sample code ? Kohei seems to have a working version with source below. I had trouble finding source for the other calc extensions listed on site. I understand that situation is complicated with taking over working code and existing docs. It may take some time to get those things in order. I am a user of LO api and don't want to look like demanding regime change (like "LO spring" driven by nabble instead of facebook :-)) If it is feasible to dedicate space for source of extensions, I have a feeling space requirements there might grow quickly. That said, I know it may take time getting these one off things done with everyone having current deadlines and some of you are working on this part time. The current examples that come bundled are all great. They focus on single feature and demonstrate it well. All the ones I tried, compiled. Thanks Neeraj -Original Message- From: libreoffice-bounces+neeraj.rai=citi@lists.freedesktop.org [mailto:libreoffice-bounces+neeraj.rai=citi@lists.freedesktop.org] On Behalf Of Stephan Bergmann Sent: Thursday, January 10, 2013 3:45 AM To: libreoffice@lists.freedesktop.org Subject: Re: [libreoffice-dev] - questions about calc extension On 01/09/2013 07:41 PM, Kohei Yoshida wrote: > On 01/09/2013 01:12 PM, Rai, Neeraj wrote: >> What is the correct way to get a >> handle to spreadsheet in extension code. > > I don't want you to look too close to this (since I no longer maintain > this), bug this code of mine > > http://code.google.com/p/scsolver/source/browse/source/ui/xcalc.cxx > > may give you some hint, especially the top 3 methods, > getCurrentComponent(), updateCurrentComponent(), and getServiceManager() > should give you how to get the current component object from the current > context object. As an extension, you are given access to the current > context object, and you can reach the current component from that one > way or another. Some comments on the above code, for the benefit of fresh development: Obtaining the com.sun.star.frame.Desktop service (variable xDesktop) in updateCurrentComponent can be greatly simplified through the use of so-called new-style service constructors (and Noel's ongoing work of changing existing old-style services into new-style ones in UNOIDL): Reference< frame::XDesktop2 > xDesktop( frame::Desktop::create(m_xCC)); - It already returns the proper interface of the service (in this case XDesktop2, derived from XDesktop), so no need for querying from XInterface to the correct type. - It directly uses the component context, no need for the service manager. (In general, demand for explicitly using the service manager should go away more and more over time.) Stephan ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
RE: [libreoffice-dev] - questions about calc extension
On Wed, 2013-01-09 at 23:18 +, Rai, Neeraj wrote: > I looked a little more into your code and copied the getactiveSheet function. > Now it takes 12s. I am happy. > Sorry for the spam - you have good code sitting there. 12s sounds like a long time to me ;-> If you can run your macro under callgrind: export OOO_DISABLE_RECOVERY=1 valgrind --tool=callgrind --simulate-cache=yes \ --dump-instr=yes ./soffice.bin -writer --splash-pipe=0 (needs write-permission to the installed libreoffice directory to drop it's callgrind.12345.txt file) Then perhaps kcachegrind will show you something interesting for your use-case. HTH, Michael. -- michael.me...@suse.com <><, Pseudo Engineer, itinerant idiot ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: [libreoffice-dev] - questions about calc extension
On 01/09/2013 07:41 PM, Kohei Yoshida wrote: On 01/09/2013 01:12 PM, Rai, Neeraj wrote: What is the correct way to get a handle to spreadsheet in extension code. I don't want you to look too close to this (since I no longer maintain this), bug this code of mine http://code.google.com/p/scsolver/source/browse/source/ui/xcalc.cxx may give you some hint, especially the top 3 methods, getCurrentComponent(), updateCurrentComponent(), and getServiceManager() should give you how to get the current component object from the current context object. As an extension, you are given access to the current context object, and you can reach the current component from that one way or another. Some comments on the above code, for the benefit of fresh development: Obtaining the com.sun.star.frame.Desktop service (variable xDesktop) in updateCurrentComponent can be greatly simplified through the use of so-called new-style service constructors (and Noel's ongoing work of changing existing old-style services into new-style ones in UNOIDL): Reference< frame::XDesktop2 > xDesktop( frame::Desktop::create(m_xCC)); - It already returns the proper interface of the service (in this case XDesktop2, derived from XDesktop), so no need for querying from XInterface to the correct type. - It directly uses the component context, no need for the service manager. (In general, demand for explicitly using the service manager should go away more and more over time.) Stephan ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
RE: [libreoffice-dev] - questions about calc extension
Hi Kohei, I looked a little more into your code and copied the getactiveSheet function. Now it takes 12s. I am happy. Sorry for the spam - you have good code sitting there. Thanks Neeraj -Original Message- From: Rai, Neeraj [ICG-MKTS] Sent: Wednesday, January 09, 2013 6:03 PM To: 'libreoffice@lists.freedesktop.org' Subject: RE: [libreoffice-dev] - questions about calc extension Hi Kohei, I figured out my bug. I was storing the context in a const Reference <> & const and it was going out of scope and being reclaimed after the constructor. After changing it to normal Reference <>, everything is fine. Thanks again for your time and patience. Hope you didn't have to waste any time based on last reply. I tested updating 60K cells using this extension. It takes 90s. Is that acceptable performance ? Seems slow. Anyway, that is a separate discussion and not critical. The main part was solved by your code. Thanks Neeraj -Original Message- From: Rai, Neeraj [ICG-MKTS] Sent: Wednesday, January 09, 2013 4:28 PM To: 'libreoffice@lists.freedesktop.org' Subject: Re: [libreoffice-dev] - questions about calc extension Hi Kohei, 1. I think I see what you are doing, but having trouble making it work. --- my understanding of your code and the issue I face below - The create_XXX is passed the ComponentContext and you store it for future. I tried the same but the calls to xContext->getServiceManager() aborts my program. Interestingly, when the create_XXX is called, I try a fake xContext->getServiceManager() and it works. when I store it in my object , in the ctor, I try another fake xContext->getServiceManager() and it works. its only when I choose my custom function from menu and invoke this again, that the app terminates. Is there anything special about functions calls from menu. Also, if the above commentary is misleading, you could look at the code create_CalcAddinCpp_impl is parallel to your create_SolverImpl (line 520: success) CalcAddinCpp_impl is parallel to your CalcInterface (line 88: success) methodTwo (line 159: calc terminates) Is xcalc.cxx a working extension code that I can download and use ? If not, do you know of other working samples ? I would greatly appreciate any sample LO calc extension code to get my env working. 2. Your sample code answered my 2nd question . If I can get a context and spreadsheet, I can access different cells. I was trying to update different cells from single menu based function call. appreciate your time. The sample I based on was on wiki.openoffice.org which seems to be down Thanks Neeraj ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
RE: [libreoffice-dev] - questions about calc extension
Hi Kohei, I figured out my bug. I was storing the context in a const Reference <> & const and it was going out of scope and being reclaimed after the constructor. After changing it to normal Reference <>, everything is fine. Thanks again for your time and patience. Hope you didn't have to waste any time based on last reply. I tested updating 60K cells using this extension. It takes 90s. Is that acceptable performance ? Seems slow. Anyway, that is a separate discussion and not critical. The main part was solved by your code. Thanks Neeraj -Original Message- From: Rai, Neeraj [ICG-MKTS] Sent: Wednesday, January 09, 2013 4:28 PM To: 'libreoffice@lists.freedesktop.org' Subject: Re: [libreoffice-dev] - questions about calc extension Hi Kohei, 1. I think I see what you are doing, but having trouble making it work. --- my understanding of your code and the issue I face below - The create_XXX is passed the ComponentContext and you store it for future. I tried the same but the calls to xContext->getServiceManager() aborts my program. Interestingly, when the create_XXX is called, I try a fake xContext->getServiceManager() and it works. when I store it in my object , in the ctor, I try another fake xContext->getServiceManager() and it works. its only when I choose my custom function from menu and invoke this again, that the app terminates. Is there anything special about functions calls from menu. Also, if the above commentary is misleading, you could look at the code create_CalcAddinCpp_impl is parallel to your create_SolverImpl (line 520: success) CalcAddinCpp_impl is parallel to your CalcInterface (line 88: success) methodTwo (line 159: calc terminates) Is xcalc.cxx a working extension code that I can download and use ? If not, do you know of other working samples ? I would greatly appreciate any sample LO calc extension code to get my env working. 2. Your sample code answered my 2nd question . If I can get a context and spreadsheet, I can access different cells. I was trying to update different cells from single menu based function call. appreciate your time. The sample I based on was on wiki.openoffice.org which seems to be down Thanks Neeraj ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: [libreoffice-dev] - questions about calc extension
Hi Kohei, 1. I think I see what you are doing, but having trouble making it work. --- my understanding of your code and the issue I face below - The create_XXX is passed the ComponentContext and you store it for future. I tried the same but the calls to xContext->getServiceManager() aborts my program. Interestingly, when the create_XXX is called, I try a fake xContext->getServiceManager() and it works. when I store it in my object , in the ctor, I try another fake xContext->getServiceManager() and it works. its only when I choose my custom function from menu and invoke this again, that the app terminates. Is there anything special about functions calls from menu. Also, if the above commentary is misleading, you could look at the code create_CalcAddinCpp_impl is parallel to your create_SolverImpl (line 520: success) CalcAddinCpp_impl is parallel to your CalcInterface (line 88: success) methodTwo (line 159: calc terminates) Is xcalc.cxx a working extension code that I can download and use ? If not, do you know of other working samples ? I would greatly appreciate any sample LO calc extension code to get my env working. 2. Your sample code answered my 2nd question . If I can get a context and spreadsheet, I can access different cells. I was trying to update different cells from single menu based function call. appreciate your time. The sample I based on was on wiki.openoffice.org which seems to be down Thanks Neeraj CalcAddinCpp_impl.cxx Description: CalcAddinCpp_impl.cxx ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: [libreoffice-dev] - questions about calc extension
On 01/09/2013 01:12 PM, Rai, Neeraj wrote: Q1. When I try to use the xContext = cppu::bootstrap() in a calc extension, app terminate with throwing an exception : cppu::BootstrapException It works well in standalone exec. Yes, that's only for "standalone exec" (or whatever we are supposed to call it), not for extensions. What is the correct way to get a handle to spreadsheet in extension code. I don't want you to look too close to this (since I no longer maintain this), bug this code of mine http://code.google.com/p/scsolver/source/browse/source/ui/xcalc.cxx may give you some hint, especially the top 3 methods, getCurrentComponent(), updateCurrentComponent(), and getServiceManager() should give you how to get the current component object from the current context object. As an extension, you are given access to the current context object, and you can reach the current component from that one way or another. Q2. I came across an example extension code that registers 4 methods. One of the methods takes sequence of sequence and returns a sequence of sequence after adding 4 to it. When I call this example by hitting (insert function) and choosing that funcname, and giving it a range of cell, the cell is populated with the value of 1st cell + 4 How can I update multiple cells using a custom written function. Not sure if I understand this fully. Can you post the URL to the example extension code that you are referring to? Kohei -- Kohei Yoshida, LibreOffice hacker, Calc ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice
[libreoffice-dev] - questions about calc extension
Q1. When I try to use the xContext = cppu::bootstrap() in a calc extension, app terminate with throwing an exception : cppu::BootstrapException It works well in standalone exec. What is the correct way to get a handle to spreadsheet in extension code. Q2. I came across an example extension code that registers 4 methods. One of the methods takes sequence of sequence and returns a sequence of sequence after adding 4 to it. When I call this example by hitting (insert function) and choosing that funcname, and giving it a range of cell, the cell is populated with the value of 1st cell + 4 How can I update multiple cells using a custom written function. Thanks Neeraj ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice