Hi everyone,
thx to Niklas and Daniel i got it running. Attached you find a Java
class which can be registered with XEnhancedMouseClickBroadcaster.
please have a look at it. i am looking forward to your feedback.
still some questions remain:
1. does it make sense to create a UNO package out of it wrapping some OO
basic macro around it to make an oxt extension out of it? Or how else
could this packaging thing be done?
2. anything about creating a custom mouse cursor? would be nice to see a
rubber/pencil as the mouse cursor.
thx
Daniel Rentz wrote:
Max Giesbert schrieb:
actually i have problems with the very first line of code you sent:
acc =
ThisComponent.CurrentController.Frame.ComponentWindow.AccessibleContext
i am doing development right now using java. so i do get the
ComponentWindow by:
XWindow window = xController.getFrame().getComponentWindow();
but how do i get the AccessibleContext from XWindow?
The Window should support the XAccessible interface, which in turn
contains one function getAccessibleContext() that returns the
XAccessibleContext interface.
XAccessible acc =
(XAccessible)UnoRuntime.queryInterface(XAccessible.class, window);
XAccessibleContext accessibleContext = acc.getAccessibleContext();
Daniel
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Max Giesbert - exactt technology
Schießstättstr. 16 T: +49 17 75 07 53 44
D-80339 München F: +49 89 1 22 21 97 02
package de.exactt.openoffice;
import com.sun.star.accessibility.XAccessible;
import com.sun.star.accessibility.XAccessibleComponent;
import com.sun.star.accessibility.XAccessibleContext;
import com.sun.star.accessibility.XAccessibleTable;
import com.sun.star.awt.EnhancedMouseEvent;
import com.sun.star.awt.XEnhancedMouseClickHandler;
import com.sun.star.awt.XWindow;
import com.sun.star.beans.PropertyVetoException;
import com.sun.star.beans.UnknownPropertyException;
import com.sun.star.beans.XPropertySet;
import com.sun.star.frame.XController;
import com.sun.star.frame.XModel;
import com.sun.star.lang.EventObject;
import com.sun.star.lang.IllegalArgumentException;
import com.sun.star.lang.IndexOutOfBoundsException;
import com.sun.star.lang.WrappedTargetException;
import com.sun.star.sheet.XCellAddressable;
import com.sun.star.sheet.XEnhancedMouseClickBroadcaster;
import com.sun.star.sheet.XSheetCellCursor;
import com.sun.star.sheet.XSpreadsheet;
import com.sun.star.sheet.XSpreadsheetView;
import com.sun.star.table.CellAddress;
import com.sun.star.table.TableBorder;
import com.sun.star.table.XCell;
import com.sun.star.uno.UnoRuntime;
/**When added to [EMAIL PROTECTED] XEnhancedMouseClickBroadcaster} this class either rubbers or draws borders depending on the contructor called.
* @author Max Giesbert
* @version 0.1
* released under the LGPLv2
* 2007-06-26
* */
public class MouseClickHandler implements XEnhancedMouseClickHandler
{
private XAccessibleTable accessibleTable = null;
private XController xController = null;
private XModel xSpreadsheetModel = null;
private static final int TOP = 0;
//private static final int BOTTOM = 1;
private static final int LEFT = 2;
//private static final int RIGHT = 3;
private int color;
private short inner;
private short outer;
private short distance;
private boolean remove = true;
//private Object oldSelection;
/**call this constructor to let the border specified by the parameters be drawn
* */
public MouseClickHandler(XController xController, XModel xSpreadsheetModel, int color, int inner, int outer, int distance)
{
init(xController, xSpreadsheetModel);
this.color = color;
this.inner = (short) inner;
this.outer = (short) outer;
this.distance = (short) distance;
remove = false;
}
/**call this contructor to let the border be removed/rubbered
* */
public MouseClickHandler(XController xController, XModel xSpreadsheetModel)
{
init(xController, xSpreadsheetModel);
remove = true;
}
/**initialization stuff that is called from both contructors
* */
private void init(XController xController, XModel xSpreadsheetModel)
{
this.xController = xController;
this.xSpreadsheetModel = xSpreadsheetModel;
XWindow window = xController.getFrame().getComponentWindow();
XAccessible accessible = (XAccessible) UnoRuntime.queryInterface(XAccessible.class, window);
XAccessibleContext accessibleContext = accessible.getAccessibleContext();
XAccessibleContext table = getAccessibleForRole(accessibleContext, com.sun.star.accessibility.AccessibleRole.TABLE);
accessibleTable = (XAccessibleTable) UnoRuntime.queryInterface(XAccessibleTable.class, table);
}
@Override
public boolean mousePressed(EnhancedMouseEvent arg0)
{
//TODO make this work! see end of mouseReleased()
//oldSelection = xSpreadsheetModel.getCurrentController().getViewData();
return true;
}
/**this method