Hi Ariel,
keeping the original dispatch of the graphics dialog causes that randomly my dispatcher or
the original dispatcher is called at an "image double-click" event.
my querydispatch() looks like below, I just call the queryDispatch of the slaveDispatchProvider
and keep the returned Dispatch object in a map to call it later if needed. Can you see why
this is causing that my dispatch isn't always called by .uno:GraphicDialog and .uno:InsertGraphic
? When I don't call the original queryDispatch my dispatch is always called, but calling
a slaves queryDispatch shouldn't do nothing else then returning me a dispatch object or am
I wrong?
@Override
public XDispatch queryDispatch(URL aURL, String sTargetFrameName, int iSearchFlags) {
if (aURL.Complete.equalsIgnoreCase(".uno:GraphicDialog") || aURL.Complete.equalsIgnoreCase(".uno:InsertGraphic"))
{
//originalDispatchMap<String,XDispatch>
XDispatch xDispatch = getSlaveDispatchProvider().queryDispatch(aURL, sTargetFrameName,
iSearchFlags);
originalDispatchMap.put(aURL.Complete, xDispatch);
return this;
}
return getSlaveDispatchProvider().queryDispatch(aURL, sTargetFrameName, iSearchFlags);
}
regards,
Fabian
On Feb 16, 2012, at 9:41 AM, fabian wrote:
> Hi Ariel,
>
> after trying a little I came to the same solution that using the dispatch as a "proxy"
is how to do it. Another idea which I thought should work is to to set the requery property
of .uno:GraphicDialog to true in addStatuslistener and request to call querydispatch every
time but I don't know if that even works. At least it failed for me when trying it out.
>
> Thank you!
>
> regards,
> Fabian
>
>
> On Feb 16, 2012, at 3:43 AM, Ariel Constenla-Haile wrote:
>
>>
>> Hi Fabian,
>>
>> On Wed, Feb 15, 2012 at 10:42:26AM +0100, fabian wrote:
>>> Hi Ariel,
>>>
>>> thx, good to know!
>>>
>>> I just got back to the Dispatchinterceptor since I had to resolve
>>> other issues first. As you mentioned I intercepted the events for:
>>> ".uno:GraphicDialog" and ".uno:InsertGraphic".
>>>
>>> Now I want to only intercept the event if an image of interest was
>>> double-clicked. Am I right that neither the call of querydipatch nor
>>> the actual dispatch call (within my interceptor) gives me the source
>>> of the event, so what image was doublecklicked?
>>
>> you are right
>>
>>> I guess when query dispatch is called I have to check if one of the
>>> two uno commands above was triggered and get the selected image (using
>>> xSelectionSupplier) to check if the image is of interest to me, then
>>> I return my own dispatcher. Otherwise I return the slave
>>> dispatchPprovider.
>>>
>>> Is that a proper way to do it?
>>
>> no, because this won't work in every case. For example, the menu item
>> Insert - Picture - From File... In the case you don't have
>> the accessibility feature enabled, menu items in the menu bar only query
>> for a dispatch object when the popup menu they belong to gets activated.
>>
>> Let's suppose the following scenario:
>>
>> - you open a Writer document
>> - your interceptor registers itself at the XFrame
>> - Go to Insert - Picture - From File...
>> - your interceptor gets queried for .uno:InsertGraphic
>> - because no image is selected, you return the slave dispatcher's
>> dispatch
>> - this way, the Insert Picture dialog shows up, you select an image, and
>> insert it. The inserted image remains selected after inserting it
>> - Go again to Insert - Picture - From file...
>> - Problem: the menu implementation caches dispatch objects, so it won't
>> query your interceptor again, instead it has the dispatch object
>> provided by your slave: the image is selected, so this menu item will
>> end up showing the Picture Properties dialog you want to avoid.
>>
>> IMO the solution here is to return always your dispatch object when the
>> interceptor gets queried for .uno:GraphicDialog and .uno:InsertDialog,
>> and add to dispatch() all the logic that decides whether to dispatch
>> your custom implementation or AOO's one.
>>
>> In queryDispatch() it may be useful to store also the AOO dispatch, for
>> later user in dispatch() in case you want to use AOO implementation (the
>> Insert Picture dialog, or the Picture Properties dialog).
>>
>> Resuming:
>>
>> - in queryDispatch(): if the URL represents one of the commands: store
>> the dispatch object returned by your slave, return your own dispatch
>> object
>>
>> - in dispatch():
>> - if the command is .uno:InsertGrapic, check if an image is selected,
>> and if that image is of your interest. If so, tell your dispatch to
>> dispatch the request; if not, tell your slave's dispatch
>> - if the command is .uno:GraphicDialog, then you can be sure an image
>> is selected. If you want to intercept every image, dispatch the
>> request with your dispatch object. If you are interested in some
>> images only, proceed as above.
>>
>>
>> That's all I can imagine right now. Hope that helps.
>>
>>
>> Regards
>> --
>> Ariel Constenla-Haile
>> La Plata, Argentina
>
|