incubator-ooo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fabian <...@netempire.de>
Subject Re: [EXT] image double click
Date Mon, 20 Feb 2012 17:34:46 GMT
Hi Ariel,

in my case I can reproduce the behavior by double-clicking an image when it hasn't been selected
before. In this case the image dialog appears every time, also my query dispatch with .uno:ImageDialog
is called every timeā€¦ addstatuslistener and removestatuslistener are called.

In your implementation you intercept the imageDialog all the time and therefore don't need
to call its original queryDispatch. I wonder if your implementation is still working if you
also call the queryDispatch of  .uno:ImageDialog as  in my case? Or have you also done that?


I put the whole implementation of my interceptor below. I changed the queryDispatch a little
so it looks more like yours and I am only checking for imageDialog right now. Besides that
my interceptor is instanciated by a synchronous jobs at the events onNew and onLoad and as
expected my interceptor is  registered once when open office starts.
 
//////////////////////////////////////////////////////////////////////////////////////
public class GraphicsInterceptor implements
        XDispatchProviderInterceptor,
        XDispatch {

    private XDispatchProvider slaveDispatchProvider;
    private XDispatchProvider masterDispatchProvider;
    private XDispatch m_xInsertGraphicDispatch;


    // Default constructor
    public GraphicsInterceptor() {
    }

    // com.sun.star.frame.XDispatchProvider:
    public com.sun.star.frame.XDispatch queryDispatch(
            com.sun.star.util.URL aURL,
            String TargetFrameName,
            int SearchFlags) {
        XDispatch xRet = null;
        synchronized (this) {
            if (aURL.Complete.equalsIgnoreCase(".uno:GraphicDialog") ) {

                if (slaveDispatchProvider != null) {
                    m_xInsertGraphicDispatch = slaveDispatchProvider.queryDispatch(aURL, TargetFrameName,
SearchFlags);
                } else {
                    m_xInsertGraphicDispatch = null;
                }

                return this;
            }
            if (slaveDispatchProvider != null) {
                xRet = slaveDispatchProvider.queryDispatch(aURL, TargetFrameName, SearchFlags);

            }
            return xRet;
        }
    }

    @Override
    public XDispatch[] queryDispatches(DispatchDescriptor[] arg0) {
        Log.info("queryDispatches was called");
        return new XDispatch[0];
    }

    @Override
    public void dispatch(URL aURL, PropertyValue[] arg1) {

        if (aURL.Complete.equalsIgnoreCase(".uno:GraphicDialog") || aURL.Complete.equalsIgnoreCase(".uno:InsertGraphic"))
{
            Document currentDocument = AddOn.getInstance().getCurrentDocument();
            String guid = currentDocument.getDocumentHelper().getGuidOfSelectedComponent();
            if (guid != null && guid.startsWith(Constants.ADDON_PREFIX)) {
                Image image = currentDocument.getImageByGuid(guid.replace(Constants.ADDON_PREFIX,
""));
                if (image != null) {
                    DialogManager.showDialog(image);
                    return;
                }
            }
        }
        m_xInsertGraphicDispatch.dispatch(aURL, arg1);
    }

    @Override
    public void addStatusListener(XStatusListener xControl, URL aURL) {
    Log.info("addStatusListener was called");
        
}

    @Override
    public void removeStatusListener(XStatusListener arg0, URL arg1) {
        Log.info("removeStatusListener was called");
    }

    @Override
    public XDispatchProvider getSlaveDispatchProvider() {
        return slaveDispatchProvider;

    }

    @Override
    public void setSlaveDispatchProvider(XDispatchProvider arg0) {
        slaveDispatchProvider = arg0;
    }

    @Override
    public XDispatchProvider getMasterDispatchProvider() {
        return masterDispatchProvider;
    }

    @Override
    public void setMasterDispatchProvider(XDispatchProvider arg0) {
        masterDispatchProvider = arg0;
    }
}

thanks!
kind regards,
Fabian



On Feb 6, 2012, at 2:19 PM, Ariel Constenla-Haile wrote:

> Hi Fabian,
> 
> On Mon, Feb 06, 2012 at 11:58:33AM +0100, fabian wrote:
>> Hi,
>> 
>> I am trying to find out if one can override the event when
>> double-clicking on an embedded image within a writer document.  For my
>> extension I would like to embed an image and when double-clicking it
>> I would like to trigger my own action instead of the default "image
>> dialog" which pops up. 
> 
> not that this dialog is shown not only on double-clicking an image:
> 
> - if the image is selected, the "Insert" - "Picture" - "From file..."
>  menu item does not insert a picture but shows the picture properties
>  dialog
> - the same happens with the icon in the "Picture" toolbar
> - if the image is selected, the context menu has a "Picture..." item
>  that triggers the Picture dialog
> - that dialog can be executed using the keyboard instead of the mouse
> - ...
> 
> 
>> 
>> I tried to use com.sun.star.document.XEventListener and
>> com.sun.star.view.XSelectionChangeListener to catch the click event.
>> But so far without success.
>> 
>> Is catching this event even possible via the api?
> 
> IMO it would work better to intercept the commands, with an
> XDispatchProviderInterceptor:
> http://www.openoffice.org/api/docs/common/ref/com/sun/star/frame/XDispatchProviderInterceptor.html
> Just intercept 
> - ".uno:GraphicDialog"
> - ".uno:InsertGraphic"
> and when an image is selected, return your dispatch object in
> queryDispatch().
> 
> This adds an extra level of complexity to your extension, you will have
> to implement an css.task.Job to register your dispatch interceptor.
> http://www.openoffice.org/api/docs/common/ref/com/sun/star/task/Job.html
> http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/Jobs/Implementation
> 
> IIRC there are examples in the SDK.
> 
> 
> Regards
> -- 
> Ariel Constenla-Haile
> La Plata, Argentina


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message