Intercepting Hyperlinks from Java

Java, C++, C#, Delphi, ??? - Using the UNO bridges

Intercepting Hyperlinks from Java

Postby bracho » Wed Feb 08, 2012 12:26 am

Hi everyone.

I'm running OpenOffice Writer through a Java application and I'm desperately trying to intercept clicks on hyperlinks.

I refered to this topic in oooforum this topic in oooforum and managed to get interception on .uno commands (save, save as, etc.).

But I did not find how to intercept hyperlinks. Still wondering wether this could be done through a dispatch interceptor on the frame.

Anyone has an idea ?

Many thanks in advance.
OOo 3.3 on MS Windows XP
bracho
 
Posts: 11
Joined: Sat Dec 13, 2008 3:23 am

Re: Intercepting Hyperlinks from Java

Postby Villeroy » Wed Feb 08, 2012 1:15 am

In the SDK there used to be an example for a ProtocolHandler add-on. As far as I know, you need to implement a protocol handler for the http: protocol.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28572
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Intercepting Hyperlinks from Java

Postby bracho » Wed Feb 08, 2012 9:28 am

Many thanks for your reply, Villeroy.

I'll keep digging in this direction and will let you know if it's a success...
OOo 3.3 on MS Windows XP
bracho
 
Posts: 11
Joined: Sat Dec 13, 2008 3:23 am

Re: Intercepting Hyperlinks from Java

Postby hanya » Wed Feb 08, 2012 1:35 pm

It seems to open hyperlink on documents does not pass through dispatch framework. I tried to make a protocol handler for http protocol but it does not used at the link opening. When I set a http item for one of menu item, it called.

But link to the file is opened by css.system.SystemShellExecute service. So I have tried to replace it with my one: http://extensions.services.openoffice.o ... ultBrowser
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
hanya
Volunteer
 
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Intercepting Hyperlinks from Java

Postby bracho » Wed Feb 08, 2012 10:08 pm

Many thanks for your response, hanya.

I dezipped your extension and try to understand how you wrote it, but I'm discovering oxt format and python language...

By the way, one question, though : in your search, did you consider intercepting mouse clicks, trying then to determine if the pointer is on a hyperlink ?

I'm asking because I would have liked to intercept clicks on hyperlinks, even those which don't lead to opening a browser (for instance, leading to a file or to a bookmark.

Thanks once again for helping.
Last edited by bracho on Thu Feb 09, 2012 11:03 am, edited 1 time in total.
OOo 3.3 on MS Windows XP
bracho
 
Posts: 11
Joined: Sat Dec 13, 2008 3:23 am

Re: Intercepting Hyperlinks from Java

Postby hanya » Thu Feb 09, 2012 7:37 am

By the way, one question, though : in your search, did you consider intercepting mouse clicks, tryning then to determine if the pointer is on a hyperlink ?
MouseHandler and accessibility api might be used this task.
Jump to bookmark is executed by .uno:JumpToMark and opening another file with link is done by .uno:Open command, it seems. So, keyword for this way is css.frame.XDispatchProviderInterception.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
hanya
Volunteer
 
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: Intercepting Hyperlinks from Java

Postby bracho » Thu Feb 09, 2012 10:51 am

Many thanks hanya.

I believe intercepting "jump to bookmark" will be just fine for my needs.

Unfortunately, I did not succeed in intercepting this command url. I'm actually trying to adapt this code :

Code: Select all   Expand viewCollapse view
public class MyInterceptor implements XDispatchProviderInterceptor {

   private XDispatchProvider slaveDispatchProvider;
   private XDispatchProvider masterDispatchProvider;
   
   public XDispatchProvider getMasterDispatchProvider() {
      return masterDispatchProvider;
   }

   public XDispatchProvider getSlaveDispatchProvider() {
      return slaveDispatchProvider;
   }

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

   public void setSlaveDispatchProvider(XDispatchProvider arg0) {
      slaveDispatchProvider = arg0;
       
   }
   /**
    * intercepts the command URLs and dispatches to the user defined handlers.
    */
   public XDispatch queryDispatch(URL arg0, String arg1, int arg2) {
      // To intercept the .uno:Save
      if(arg0.Complete.equals(".uno:Save")) {
         // your command handler
         return new MySave();
      } else if(arg0.Complete.equals(".uno:Paste")) {
         // return your paste command handler
      }   
      return getSlaveDispatchProvider().queryDispatch(arg0, arg1, arg2); // to get next command url.
   }

   public XDispatch[] queryDispatches(DispatchDescriptor[] arg0) {
      return getSlaveDispatchProvider().queryDispatches(arg0);
   }


called from :

Code: Select all   Expand viewCollapse view
XDispatchProviderInterception xDPI = (XDispatchProviderInterception) UnoRuntime.queryInterface(XDispatchProviderInterception.class, xFrame);
MyInterceptor interceptor = new MyInterceptor();
xDPI.registerDispatchProviderInterceptor(interceptor);


But, doing so, I'm only able to intercept commands that are present in menus or toolbars.

Sorry to bother you with that, but could you give me a clue (or a piece of code) that would allow me to intercept the ".uno:JumpToBookmark" command ?

Many thanks once again !
OOo 3.3 on MS Windows XP
bracho
 
Posts: 11
Joined: Sat Dec 13, 2008 3:23 am

Re: Intercepting Hyperlinks from Java

Postby hanya » Thu Feb 09, 2012 1:40 pm

I am sorry for that I have not tried to capture JumpToBookmark call by clicking hyperlinks. It does not work on my environment also.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
hanya
Volunteer
 
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan


Return to External Programs

Who is online

Users browsing this forum: No registered users and 1 guest