[libreoffice-dev] - questions about calc extension
Stephan Bergmann
sbergman at redhat.com
Thu Jan 10 00:45:03 PST 2013
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
More information about the LibreOffice
mailing list