Hi,

I managed to create button control and put that on a slide of ooimpress
document. But when I tried to hook this button with an actionListener so
that I get notified whenever button is clicked, i found that draws
controller does not implement getControl method on linux. Therefore
xController returned by the getCurrentController method of XModel returns
null when I ask it for the XControlAccess.

following is the code of function I'm using to hook the button with the
actionListener
/**********************************************************************************
hookButton function start
**********************************************************************************/

1) public void hookButton( XPropertySet xButtonModel,
XComponent  xDrawComponent ) throws java.lang.Exception
{
2) System.out.println("Entering hookButton");
// get the model interface for the document
3)       XModel xDocModel = (XModel)UnoRuntime.queryInterface(XModel.class,
xDrawComponent );
      // get the current controller for the document - as a controller is
tied to a view,
      // this gives us the currently active view for the document.
4) XController xController = xDocModel.getCurrentController();

5) if( xController != null )
6) System.out.println("xConroller is not null");
7) else
8) System.out.println("xCtroller is null");

9) XControlModel xControlModel = (XControlModel)UnoRuntime.queryInterface(
XControlModel.class, xButtonModel );

10) if( xControlModel != null )
11) System.out.println("xConrolModel is not null");
12) else
13) System.out.println("xControlModel is null");

// the current view of the document
14)       XControlAccess xCtrlAcc =
(XControlAccess)UnoRuntime.queryInterface( XControlAccess.class ,
xController );

15) if( xCtrlAcc != null )
16) System.out.println("xCtrlAcc is not null");
17) else
18) System.out.println("xCtrlAcc is null");

19)       XControl xControl = xCtrlAcc.getControl( xControlModel );

20) if( xControl != null )
21) System.out.println("xConrol is not null");
// add a listener so we get notified if the user presses the button
// get the control
22) XButton xButtonControl = (XButton)UnoRuntime.queryInterface(
XButton.class, xControl );

23) xButtonControl.addActionListener( this );

24) System.out.println("leaving hookButton");
}
// *********************** hookButton function end
*************************
So on line 14 UnoRuntime.queryInterface( XControlAccess.class, xController )
returns null, function prints "xCtrlAcc is null" on reaching at line 18, and
null pointer exception is raised at line 19. I'm particularly talking about
ooimpress, this function works as expected for oowriter.

I actually read at http://www.oooforum.org/forum/viewtopic.phtml?p=32361#32361
 that "Alas, Draw on Linux does not work because Draw's Controller does not
implement the getControl() method. I'm going to file an enhancement request
for this."

I want to know if this request has been entertained. If not please guide me
how can I get the functionality similar to being notified in the
actionPerformed when a button is pressed in ooimpress on a slide.

Thanks,
Zeeshan.

Reply via email to