W schrieb:
[Originally posted in OOoForum.org Forum -> "OpenOffice.org Macros and
API"]
lo,
I don´t know if this might help you, but I used the Accessibility API to
install Drag&Drop Listeners. The problem is that afaik events are not
posted through the window hierarchy. Thus, an event on the DocumentView
will not be broadcasted on the ContainerWindow. (If i´m mistaken here
please tell me)
To solve this it is possible to access the window hierarchy using the
Accessibility API. (see attached code).
I am not really happy with this solution since XVclContainer is marked
as deprecated. Anyway, it works for me.
regards
Sascha
Hi,
I have been trying to keep track of where the OO user is writing and
what is written.
First of I tried adding an XFocusListener to an instance of the
XExtendedToolkit (is this class by the way deprecated?) using the
addFocusListener method. I was not however able to trigger any events.
Next experiment was to add an XAccessibleEventListener to
XAccessibleEventBroadcasters obtained in different ways. As it is the
CARET_CHANGED event I am interested in, I even tried adding the listener
to the model window:
AccListener *accListener = new AccListener();
Reference<XAccessibleEventListener> xAccListener =
static_cast<XAccessibleEventListener* >(accListener);
Reference<XDesktop> xDesktop(desktop, UNO_QUERY);
if (xDesktop.is()) {
Reference<XComponent> xCurrentComponent =
xDesktop->getCurrentComponent();
Reference<XModel> xModel(xCurrentComponent, UNO_QUERY);
if (xModel.is()) {
Reference<XController> xCtrl = xModel->getCurrentController();
Reference<XFrame> xFrame = xCtrl->getFrame();
Reference<XWindow> xWindow = xFrame->getContainerWindow();
Reference<XAccessible> xDocAccessible(xWindow, UNO_QUERY);
if(xDocAccessible.is()) {
Reference<XAccessibleContext> xDocAccessibleContext =
xDocAccessible->getAccessibleContext();
//ACCESSIBLE EVENT LISTENER
Reference<XAccessibleEventBroadcaster>
xDocBroadcaster(xDocAccessibleContext, UNO_QUERY);
if (xDocBroadcaster.is()) {
std::cout << "Succesfully obtained a xDocBroadcaster" <<
std::endl;
xDocBroadcaster->addEventListener(xAccListener);
}
}
}
}
This does not however trigger any events. For the record I do not
believe it is my listener which is the problem as I was able to get
other events in some situations (ie BOUNDRECT_CHANGED).
I have successfully added a keylistener but I would really like to be
informed by caret movements - even if they are triggered by the mouse.
Has anyone ever listened to the the CARET_CHANGED event?
Comments and suggestions would be very much appreciated.
/W
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
void OOoWindow::_accessibilityRunner( ::css::uno::Reference<
::css::accessibility::XAccessible > accessible, bool install)
{
::css::uno::Reference< ::css::accessibility::XAccessibleContext >
context = accessible->getAccessibleContext();
// info about the context (name / description /childcount )
sal_Int32 childCount = context->getAccessibleChildCount();
bool doInstall = false;
// we only want to install into the window with role SCROLL_PANE.
if( install != true) {
if ( context->getAccessibleRole() ==
com::sun::star::accessibility::AccessibleRole::SCROLL_PANE) {
//::css::uno::Reference<::css::awt::XWindow>
_xScrollPaneWindow;
doInstall = true;
}
}
if( doInstall == true )
{
::css::uno::Reference< ::css::awt::XWindow > win(accessible,
::css::uno::UNO_QUERY );
if( install == true && win.is()) {
// install a DropTargetListener for the window
installDropTargetListenerForWindow( win );
}
::css::uno::Reference< ::css::awt::XVclContainer > container(
accessible, ::css::uno::UNO_QUERY );
if( container.is())
{
::css::uno::Sequence< ::css::uno::Reference<
::css::awt::XWindow > > theWindows = container->getWindows();
sal_Int32 winCount = theWindows.getLength();
for ( sal_Int32 i=0; i < winCount ; i++) {
::css::uno::Reference< ::css::awt::XWindow >
aWindow = theWindows[i];
// install a DropTargetListener for the window
installDropTargetListenerForWindow( aWindow );
}
}
}
// check all accessible children
for( sal_Int32 index = 0; index < childCount; index ++)
{
::css::uno::Reference< ::css::accessibility::XAccessible >
accessibleChild = context->getAccessibleChild(index);
_accessibilityRunner(accessibleChild, doInstall);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]