You are viewing a plain text version of this content. The canonical link for it is here.
Posted to api@openoffice.apache.org by Антон Борисов <an...@gmail.com> on 2014/02/02 23:14:16 UTC

Re: Multiple instances of main extesion's class

my extension is having something like Model (which consists of Nodes
(customized shapes) and Links (customized connector shapes)) of current
document. I've added handlers of documents events to keep model in actual
state.

when user is saving/loading document some handler stores/restores this
model using UserDefinedProperties of document


my main class extends WeakBase implements
        com.sun.star.lang.XInitialization,
        com.sun.star.task.XJob,
        com.sun.star.frame.XDispatchProvider,
        com.sun.star.lang.XServiceInfo,
        com.sun.star.util.XCloseable,
        com.sun.star.task.XAsyncJob,
        com.sun.star.frame.XDispatch,
        com.sun.star.frame.XFrameActionListener,
        com.sun.star.document.XEventListener,
        XComponent

and supports             "com.sun.star.frame.ProtocolHandler",
            "com.sun.star.task.Job",
            "com.sun.star.task.AsyncJob" services

I assume that it's creating instance for every button in toolbar or
something similar.
It's possible to do it Singleton per frame?


2014-01-29 Ariel Constenla-Haile <ar...@apache.org>:

> Hi Антон
>
> On Wed, Jan 29, 2014 at 01:43:10AM +0400, Антон Борисов wrote:
> > no reply yet :( i still have this problem, maybe someone knows
> > solution?
> >
> >
> > 2013-06-30 Антон Борисов <an...@gmail.com>
> >
> > > i noticed that for each frame openoffice creates ten instances of
> > > extesion main class. Why it's so, and how to have only one per frame
> > > ?
> > >
> > > I created my own implementation of XSingleComponentFactory which is
> > > returning in __getComponentFactory  but how to find out about frame
> > > from createInstanceWithContext method argument ?
>
> Please specify what is your extension doing; I assume that your main
> class implements a so called "Protocol Handler", as explained here
>
> https://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/Protocol_Handler
>
>
> Regards
> --
> Ariel Constenla-Haile
> La Plata, Argentina
>



-- 
Борисов Антон

Re: Multiple instances of main extesion's class

Posted by Антон Борисов <an...@gmail.com>.
Thanks for reply, now it works


2014-02-06 10:36 GMT+04:00 Ariel Constenla-Haile <ar...@apache.org>:

> On Mon, Feb 03, 2014 at 02:14:16AM +0400, Антон Борисов wrote:
> > my extension is having something like Model (which consists of Nodes
> > (customized shapes) and Links (customized connector shapes)) of current
> > document. I've added handlers of documents events to keep model in actual
> > state.
> >
> > when user is saving/loading document some handler stores/restores this
> > model using UserDefinedProperties of document
> >
> >
> > my main class extends WeakBase implements
> >         com.sun.star.lang.XInitialization,
> >         com.sun.star.task.XJob,
> >         com.sun.star.frame.XDispatchProvider,
> >         com.sun.star.lang.XServiceInfo,
> >         com.sun.star.util.XCloseable,
> >         com.sun.star.task.XAsyncJob,
> >         com.sun.star.frame.XDispatch,
> >         com.sun.star.frame.XFrameActionListener,
> >         com.sun.star.document.XEventListener,
> >         XComponent
> >
> > and supports             "com.sun.star.frame.ProtocolHandler",
> >             "com.sun.star.task.Job",
> >             "com.sun.star.task.AsyncJob" services
> >
> > I assume that it's creating instance for every button in toolbar or
> > something similar.
>
> You are right.
>
> > It's possible to do it Singleton per frame?
>
> You need to split the css.frame.XDispatchProvider implementation from
> the css.frame.XDispatch. I assume your class is returning itself when
> queried for a dispatch object, it should return a "dispatch object" (an
> object implementing css.frame.XDispatch). The component controlling the
> toolbar item will use this object to dispatch the command and listen for
> status updates (if you didn't implement the add/removeStatusListener
> methods, you should do so, because toolbar items should be context
> sensitive).
>
> The XDispatchProvider can be queried for a dispatch object several times
> during the lifetime of the current document view, you should return
> always the same dispatch instance (implement some sort of dispatch pool
> that keeps track of dispatch objects per frame - the ProtocolHandler
> implementation knows its frame, it is initialized with it).
>
>
> Regards
> --
> Ariel Constenla-Haile
> La Plata, Argentina
>



-- 
Борисов Антон

Re: Multiple instances of main extesion's class

Posted by Ariel Constenla-Haile <ar...@apache.org>.
On Mon, Feb 03, 2014 at 02:14:16AM +0400, Антон Борисов wrote:
> my extension is having something like Model (which consists of Nodes
> (customized shapes) and Links (customized connector shapes)) of current
> document. I've added handlers of documents events to keep model in actual
> state.
> 
> when user is saving/loading document some handler stores/restores this
> model using UserDefinedProperties of document
> 
> 
> my main class extends WeakBase implements
>         com.sun.star.lang.XInitialization,
>         com.sun.star.task.XJob,
>         com.sun.star.frame.XDispatchProvider,
>         com.sun.star.lang.XServiceInfo,
>         com.sun.star.util.XCloseable,
>         com.sun.star.task.XAsyncJob,
>         com.sun.star.frame.XDispatch,
>         com.sun.star.frame.XFrameActionListener,
>         com.sun.star.document.XEventListener,
>         XComponent
> 
> and supports             "com.sun.star.frame.ProtocolHandler",
>             "com.sun.star.task.Job",
>             "com.sun.star.task.AsyncJob" services
> 
> I assume that it's creating instance for every button in toolbar or
> something similar.

You are right.

> It's possible to do it Singleton per frame?

You need to split the css.frame.XDispatchProvider implementation from
the css.frame.XDispatch. I assume your class is returning itself when
queried for a dispatch object, it should return a "dispatch object" (an
object implementing css.frame.XDispatch). The component controlling the
toolbar item will use this object to dispatch the command and listen for
status updates (if you didn't implement the add/removeStatusListener
methods, you should do so, because toolbar items should be context
sensitive). 

The XDispatchProvider can be queried for a dispatch object several times
during the lifetime of the current document view, you should return
always the same dispatch instance (implement some sort of dispatch pool
that keeps track of dispatch objects per frame - the ProtocolHandler
implementation knows its frame, it is initialized with it).


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina