incubator-ooo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ariel Constenla-Haile <arie...@apache.org>
Subject Re: [EXT] image double click
Date Fri, 17 Feb 2012 17:37:06 GMT

Hi Fabian,

On Fri, Feb 17, 2012 at 05:52:47PM +0100, fabian wrote:
> 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.  

this shouldn't happen if you always return your dispatch object for
those commands.

> 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. 

may be it's better volatile member variables, not a map (you don't want
to store all the dispatches returned by your slave, only the last one)

> 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?

you are right. As long a as you return your dispatch object, it does not
matter if you also ask your slave for a dispatch to store the reference
for yourself.

>   @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); }

this looks good.
So something is wrong with your implementation somewhere else.
You say it happens randomly, can't you see a pattern when it happens?
It's hard to guess without seeing the other parts of the implementation.
But if you proceed as explain in this thread, the interception should
work fine, I cannot reproduce the strange behaviour with my test:
http://people.apache.org/~arielch/api/DispatchInterceptorDemo.oxt (this
works rather slow, it has lot of debugging code, so have patience if the
UI freezes when activating the menu bar, for example).


The queryDispatch code looks similar to yours:


// com.sun.star.frame.XDispatchProvider:
public com.sun.star.frame.XDispatch queryDispatch(
        com.sun.star.util.URL URL,
        String TargetFrameName,
        int SearchFlags) {
    XDispatch xRet = null;
    synchronized (this) {
        if (m_lCommands.contains(URL.Complete)) {
            if (URL.Complete.equals(Constants.STR_COMMAND_INSERT_GRAPHIC)) {
                if (m_xSlave != null)
                    m_xInsertGraphicDispatch = m_xSlave.queryDispatch(URL, TargetFrameName,
SearchFlags);
                else
                    m_xInsertGraphicDispatch = null;
            }
            return this;
        }
        if (m_xSlave != null) {
            xRet = m_xSlave.queryDispatch(URL, TargetFrameName, SearchFlags);
        }
    }
    return xRet;
}


public void dispatch(URL aURL, PropertyValue[] aPropertyValue) {
    boolean bDispatch = true;
    if (aURL.Complete.equals(Constants.STR_COMMAND_INSERT_GRAPHIC)
            && !isGraphicObjectSelected(m_xFrame)) {
        bDispatch = false;
    }

    if (bDispatch) {
        showMessageBox(aURL.Complete);
    } else if (m_xInsertGraphicDispatch!=null){
        m_xInsertGraphicDispatch.dispatch(aURL, aPropertyValue);
    }
}

It's a little different only because it always dispatches .uno:GraphicDialog,
.uno:InsertGraphic is only dispatched when an image is selected.


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina

Mime
View raw message