hi christian,

So in order to see what is giving you problems, it would be nice to
catch a glimpse at the relevant code portion(s).

I have some code for my installation of the XDropTargetListener since
the other problem is resolved (see attachment).

This thing is really mysterious to me.

If I dont install a DropTargetListener everything works fine. I would
expect that after a PrintPreview, where the DropTargetListener is
removed completely and destroyed (see log snippet below), everything
should work too. But even with removed DropTargetListener SWriter
crashes *whenever* I insert a table into a TextFrame .


// some logfile with accompanying commentary

### File->PrintPreview
OOoDocumentEventListener::notifyEvent OnViewClosed      
OOoDropTargetListener::disposing
OOoDropTargetListener::disposing
OOoDropTargetListener::disposing
OOoDropTargetListener::disposing
OOoDropTargetListener::disposing
OOoDropTargetListener::disposing
OOoDropTargetListener::disposing
OOoDropTargetListener::disposing
OOoDropTargetListener::disposing
OOoDropTargetListener::~OOoDropTargetListener
### close print preview
OOoDocumentEventListener::notifyEvent OnViewClosed
### Insert->TexFrame
OOoDocumentEventListener::notifyEvent TitleChanged
OOoDocumentEventListener::notifyEvent OnModifyChanged
OOoDocumentEventListener::notifyEvent TitleChanged
OOoDocumentEventListener::notifyEvent OnModifyChanged
OOoDocumentEventListener::notifyEvent TitleChanged
OOoDocumentEventListener::notifyEvent OnModifyChanged
### Cursor is in TextFrame
### Insert Table into TextFrame
OOoDocumentEventListener::~OOoDocumentEventListener
### SWriter is gone


I will try to reduce my app to a minimum example.

thanks,
Sascha


/******************************************************************************************
those are the relevant methods from the window class that integrates OOo 
(SWriter)
******************************************************************************************/



/*
function to create an OOo Window
*/
void OOoIntegrationWindow::createOOoWindow()
{
        /*
                ... snip ...
        */
        _dropTargetListener = new OOoDropTargetListener(ctx); // class member
                
        // get the Accessible API and run through ut to install listeners
        ::com::sun::star::uno::Reference< 
::com::sun::star::accessibility::XAccessible > accessibleWindow ( _xwindow, 
::com::sun::star::uno::UNO_QUERY);
        if( accessibleWindow.is())
                _accessibilityRunner(accessibleWindow, false);
        /*
                ... snip ...
        */
}


/*
install the dropTargetListener for a specific XWindow
*/
void OOoIntegrationWindow::installDropTargetListenerForWindow( 
::com::sun::star::uno::Reference<::com::sun::star::awt::XWindow> window)
{

        // the Toolkit is also XDataTransferProviderAccess where we can receive 
the DropTarget for our window
        ::com::sun::star::uno::Reference< 
::com::sun::star::awt::XDataTransferProviderAccess > xDataTransferPA 
(_xtoolkit, ::com::sun::star::uno::UNO_QUERY);
        // get the OleDropTarget Service for our OpenOffice.org window 
(_xwindow)
        ::com::sun::star::uno::Reference< 
::com::sun::star::datatransfer::dnd::XDropTarget > xDropTarget = 
xDataTransferPA->getDropTarget(window);
        ::com::sun::star::uno::Reference< 
::com::sun::star::datatransfer::dnd::XDropTargetListener>  xdropTargetListener 
(_dropTargetListener);

        if( xdropTargetListener.is())
        {
                // add DropTargetListener
                xDropTarget->addDropTargetListener(xdropTargetListener);
                xDropTarget->setActive(sal_True);
        }
}
}



/*
This functions runs through the accessibility tree. It calls 
installDropTargetListenerForWindow for each window
below and including the one with the AccessibleRole SCROLL_PANE.
The XWindow´s are either the XAccessible itself or if the XAccessible offers a 
XVclContainer interface children of it.
*/
void OOoIntegrationWindow::_accessibilityRunner( 
::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible 
> accessible, bool install)
{
        ::com::sun::star::uno::Reference< 
::com::sun::star::accessibility::XAccessibleContext > context = 
accessible->getAccessibleContext();
        // info about the context (name / description /childcount )
        sal_Int32 childCount = context->getAccessibleChildCount();
        bool doInstall = false;

        if( install != true) {
                
                ::com::sun::star::uno::Reference< 
::com::sun::star::accessibility::XAccessible > accessibleParent = 
context->getAccessibleParent();
                /*if( accessibleParent.is())
                {
                        ::com::sun::star::uno::Reference< 
::com::sun::star::accessibility::XAccessibleContext > pContext = 
accessibleParent->getAccessibleContext();
                        if( pContext->getAccessibleRole() == 
com::sun::star::accessibility::AccessibleRole::SCROLL_PANE) 
                        {               
                                install = true;
                        }
                }*/
                if ( context->getAccessibleRole() == 
com::sun::star::accessibility::AccessibleRole::SCROLL_PANE) {              
                        doInstall = true;
                }

        }
        if( doInstall == true )
        {
                ::com::sun::star::uno::Reference< 
::com::sun::star::awt::XWindow > win(accessible, 
::com::sun::star::uno::UNO_QUERY );
                if( install == true && win.is())  {
                        // install a DropTargetListener for the window
                        installDropTargetListenerForWindow( win );
                }
                

                ::com::sun::star::uno::Reference< 
::com::sun::star::awt::XVclContainer > container( accessible, 
::com::sun::star::uno::UNO_QUERY );
                if( container.is())
                {
                        ::com::sun::star::uno::Sequence< 
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > > theWindows 
= container->getWindows();
                        sal_Int32 winCount = theWindows.getLength();
                        for ( sal_Int32 i=0; i < winCount ; i++)
                        {
                                ::com::sun::star::uno::Reference< 
::com::sun::star::awt::XWindow > aWindow = theWindows[i];
                                // install a DropTargetListener for the window
                                installDropTargetListenerForWindow( aWindow );
                        }
                }               
        }
        // children
        for( sal_Int32 index = 0; index < childCount; index ++)
        {
                ::com::sun::star::uno::Reference< 
::com::sun::star::accessibility::XAccessible > accessibleChild = 
context->getAccessibleChild(index);
                _accessibilityRunner(accessibleChild, doInstall);
        }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to