Thanks for reply, now it works
2014-02-06 10:36 GMT+04:00 Ariel Constenla-Haile <[email protected]>: > 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 > -- Борисов Антон
