2010-10-12 15:59:03 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2002-02-06 07:55:08 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 15:26:13 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2002-02-06 07:55:08 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2002-02-06 07:55:08 +00:00
|
|
|
*
|
2008-04-10 15:26:13 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2002-02-06 07:55:08 +00:00
|
|
|
*
|
2008-04-10 15:26:13 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2002-02-06 07:55:08 +00:00
|
|
|
*
|
2008-04-10 15:26:13 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2002-02-06 07:55:08 +00:00
|
|
|
*
|
2008-04-10 15:26:13 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2002-02-06 07:55:08 +00:00
|
|
|
*
|
2008-04-10 15:26:13 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2002-02-06 07:55:08 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-17 06:25:42 +00:00
|
|
|
|
2002-02-06 07:55:08 +00:00
|
|
|
#include "TableWindowAccess.hxx"
|
|
|
|
#include "JAccess.hxx"
|
|
|
|
#include "TableWindow.hxx"
|
|
|
|
#include "TableWindowListBox.hxx"
|
|
|
|
#include "JoinDesignView.hxx"
|
|
|
|
#include "JoinController.hxx"
|
|
|
|
#include "JoinTableView.hxx"
|
2003-04-24 16:22:58 +00:00
|
|
|
#include <com/sun/star/accessibility/AccessibleRole.hpp>
|
|
|
|
#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
|
2003-06-25 10:05:09 +00:00
|
|
|
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
|
|
|
|
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
|
2002-02-06 07:55:08 +00:00
|
|
|
#include <comphelper/sequence.hxx>
|
2002-11-26 06:46:13 +00:00
|
|
|
#include "dbu_qry.hrc"
|
2002-02-06 07:55:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace dbaui
|
|
|
|
{
|
2003-04-24 16:22:58 +00:00
|
|
|
using namespace ::com::sun::star::accessibility;
|
2002-02-06 07:55:08 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
2003-06-25 10:05:09 +00:00
|
|
|
OTableWindowAccess::OTableWindowAccess(OTableWindow* _pTable)
|
|
|
|
:VCLXAccessibleComponent(_pTable->GetComponentInterface().is() ? _pTable->GetWindowPeer() : NULL)
|
2002-02-06 07:55:08 +00:00
|
|
|
,m_pTable(_pTable)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OTableWindowAccess::disposing()
|
|
|
|
{
|
|
|
|
m_pTable = NULL;
|
2003-06-25 10:05:09 +00:00
|
|
|
VCLXAccessibleComponent::disposing();
|
2002-02-06 07:55:08 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2008-11-19 17:43:08 +00:00
|
|
|
void OTableWindowAccess::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
|
|
|
|
{
|
|
|
|
if ( rVclWindowEvent.GetId() == VCLEVENT_OBJECT_DYING )
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
m_pTable = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2002-02-06 07:55:08 +00:00
|
|
|
Any SAL_CALL OTableWindowAccess::queryInterface( const Type& aType ) throw (RuntimeException)
|
|
|
|
{
|
2003-06-25 10:05:09 +00:00
|
|
|
Any aRet(VCLXAccessibleComponent::queryInterface( aType ));
|
2002-02-06 07:55:08 +00:00
|
|
|
return aRet.hasValue() ? aRet : OTableWindowAccess_BASE::queryInterface( aType );
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Sequence< Type > SAL_CALL OTableWindowAccess::getTypes( ) throw (RuntimeException)
|
|
|
|
{
|
2003-06-25 10:05:09 +00:00
|
|
|
return ::comphelper::concatSequences(VCLXAccessibleComponent::getTypes(),OTableWindowAccess_BASE::getTypes());
|
2002-02-06 07:55:08 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL OTableWindowAccess::getImplementationName() throw(RuntimeException)
|
|
|
|
{
|
|
|
|
return getImplementationName_Static();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Sequence< ::rtl::OUString > SAL_CALL OTableWindowAccess::getSupportedServiceNames() throw(RuntimeException)
|
|
|
|
{
|
|
|
|
return getSupportedServiceNames_Static();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// XServiceInfo - static methods
|
|
|
|
Sequence< ::rtl::OUString > OTableWindowAccess::getSupportedServiceNames_Static(void) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
Sequence< ::rtl::OUString > aSupported(2);
|
2010-11-13 21:19:14 +00:00
|
|
|
aSupported[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.Accessible"));
|
|
|
|
aSupported[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.accessibility.AccessibleContext"));
|
2002-02-06 07:55:08 +00:00
|
|
|
return aSupported;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
::rtl::OUString OTableWindowAccess::getImplementationName_Static(void) throw( RuntimeException )
|
|
|
|
{
|
2010-11-13 21:19:14 +00:00
|
|
|
return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.TableWindowAccessibility"));
|
2002-02-06 07:55:08 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// XAccessibleContext
|
|
|
|
sal_Int32 SAL_CALL OTableWindowAccess::getAccessibleChildCount( ) throw (RuntimeException)
|
|
|
|
{
|
2007-06-27 11:25:46 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
sal_Int32 nCount = 0;
|
|
|
|
if(m_pTable)
|
|
|
|
{
|
|
|
|
if(m_pTable->GetTitleCtrl())
|
|
|
|
++nCount;
|
|
|
|
if(m_pTable->GetListBox())
|
|
|
|
++nCount;
|
|
|
|
}
|
|
|
|
return nCount;
|
2002-02-06 07:55:08 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2002-11-26 06:46:13 +00:00
|
|
|
Reference< XAccessible > SAL_CALL OTableWindowAccess::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException,RuntimeException)
|
2002-02-06 07:55:08 +00:00
|
|
|
{
|
2007-06-27 11:25:46 +00:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
2002-02-06 07:55:08 +00:00
|
|
|
Reference< XAccessible > aRet;
|
2007-06-27 11:25:46 +00:00
|
|
|
if(m_pTable)
|
|
|
|
{
|
|
|
|
switch(i)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if(m_pTable->GetTitleCtrl())
|
|
|
|
{
|
|
|
|
aRet = m_pTable->GetTitleCtrl()->GetAccessible();
|
|
|
|
break;
|
|
|
|
} // fall through if title control does not exist
|
|
|
|
case 1:
|
|
|
|
if(m_pTable->GetListBox())
|
|
|
|
aRet = m_pTable->GetListBox()->GetAccessible();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw IndexOutOfBoundsException();
|
|
|
|
}
|
|
|
|
}
|
2002-02-06 07:55:08 +00:00
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Int32 SAL_CALL OTableWindowAccess::getAccessibleIndexInParent( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
sal_Int32 nIndex = -1;
|
|
|
|
if( m_pTable )
|
|
|
|
{
|
|
|
|
// search the postion of our table window in the table window map
|
|
|
|
OJoinTableView::OTableWindowMap* pMap = m_pTable->getTableView()->GetTabWinMap();
|
|
|
|
OJoinTableView::OTableWindowMap::iterator aIter = pMap->begin();
|
2009-07-03 12:24:35 +00:00
|
|
|
OJoinTableView::OTableWindowMap::iterator aEnd = pMap->end();
|
|
|
|
for (nIndex = 0; aIter != aEnd && aIter->second != m_pTable; ++nIndex,++aIter)
|
2002-02-06 07:55:08 +00:00
|
|
|
;
|
2009-07-03 12:24:35 +00:00
|
|
|
nIndex = aIter != aEnd ? nIndex : -1;
|
2002-02-06 07:55:08 +00:00
|
|
|
}
|
|
|
|
return nIndex;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Int16 SAL_CALL OTableWindowAccess::getAccessibleRole( ) throw (RuntimeException)
|
|
|
|
{
|
2002-02-11 11:51:03 +00:00
|
|
|
return AccessibleRole::PANEL; // ? or may be an AccessibleRole::WINDOW
|
2002-02-06 07:55:08 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
Reference< XAccessibleRelationSet > SAL_CALL OTableWindowAccess::getAccessibleRelationSet( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// XAccessibleComponent
|
2003-04-24 16:22:58 +00:00
|
|
|
Reference< XAccessible > SAL_CALL OTableWindowAccess::getAccessibleAtPoint( const awt::Point& _aPoint ) throw (RuntimeException)
|
2002-02-06 07:55:08 +00:00
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
Reference< XAccessible > aRet;
|
|
|
|
if( m_pTable )
|
|
|
|
{
|
|
|
|
Point aPoint(_aPoint.X,_aPoint.Y);
|
|
|
|
Rectangle aRect(m_pTable->GetDesktopRectPixel());
|
|
|
|
if( aRect.IsInside(aPoint) )
|
|
|
|
aRet = this;
|
|
|
|
else if( m_pTable->GetListBox()->GetDesktopRectPixel().IsInside(aPoint))
|
|
|
|
aRet = m_pTable->GetListBox()->GetAccessible();
|
|
|
|
}
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2003-06-25 10:05:09 +00:00
|
|
|
Reference< XAccessible > OTableWindowAccess::getParentChild(sal_Int32 _nIndex)
|
|
|
|
{
|
|
|
|
Reference< XAccessible > xReturn;
|
|
|
|
Reference< XAccessible > xParent = getAccessibleParent();
|
|
|
|
if ( xParent.is() )
|
|
|
|
{
|
|
|
|
Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext();
|
|
|
|
if ( xParentContext.is() )
|
|
|
|
{
|
|
|
|
xReturn = xParentContext->getAccessibleChild(_nIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return xReturn;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2002-02-06 07:55:08 +00:00
|
|
|
sal_Int32 SAL_CALL OTableWindowAccess::getRelationCount( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
return m_pTable ? m_pTable->getTableView()->getConnectionCount(m_pTable) : sal_Int32(0);
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
AccessibleRelation SAL_CALL OTableWindowAccess::getRelation( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
if( nIndex < 0 || nIndex >= getRelationCount() )
|
|
|
|
throw IndexOutOfBoundsException();
|
|
|
|
|
|
|
|
AccessibleRelation aRet;
|
|
|
|
if( m_pTable )
|
|
|
|
{
|
2002-02-08 08:10:00 +00:00
|
|
|
OJoinTableView* pView = m_pTable->getTableView();
|
|
|
|
::std::vector<OTableConnection*>::const_iterator aIter = pView->getTableConnections(m_pTable) + nIndex;
|
2002-02-06 07:55:08 +00:00
|
|
|
aRet.TargetSet.realloc(1);
|
2003-06-25 10:05:09 +00:00
|
|
|
aRet.TargetSet[0] = getParentChild(aIter - pView->getTableConnections()->begin());
|
2002-02-06 07:55:08 +00:00
|
|
|
aRet.RelationType = AccessibleRelationType::CONTROLLER_FOR;
|
|
|
|
}
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool SAL_CALL OTableWindowAccess::containsRelation( sal_Int16 aRelationType ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
return AccessibleRelationType::CONTROLLER_FOR == aRelationType
|
2008-11-19 17:43:08 +00:00
|
|
|
&& m_pTable && m_pTable->getTableView()->ExistsAConn(m_pTable);
|
2002-02-06 07:55:08 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
AccessibleRelation SAL_CALL OTableWindowAccess::getRelationByType( sal_Int16 aRelationType ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
if( AccessibleRelationType::CONTROLLER_FOR == aRelationType && m_pTable)
|
|
|
|
{
|
2002-02-08 08:10:00 +00:00
|
|
|
OJoinTableView* pView = m_pTable->getTableView();
|
|
|
|
const ::std::vector<OTableConnection*>* pConnectionList = pView->getTableConnections();
|
2002-02-06 07:55:08 +00:00
|
|
|
|
2002-02-08 08:10:00 +00:00
|
|
|
::std::vector<OTableConnection*>::const_iterator aIter = pView->getTableConnections(m_pTable);
|
2009-07-03 12:24:35 +00:00
|
|
|
::std::vector<OTableConnection*>::const_iterator aEnd = pConnectionList->end();
|
2002-02-06 07:55:08 +00:00
|
|
|
::std::vector< Reference<XInterface> > aRelations;
|
|
|
|
aRelations.reserve(5); // just guessing
|
2009-07-03 12:24:35 +00:00
|
|
|
for (; aIter != aEnd ; ++aIter )
|
2011-09-29 23:02:56 +01:00
|
|
|
{
|
2011-10-26 12:58:49 +03:00
|
|
|
uno::Reference<uno::XInterface> xInterface(
|
|
|
|
getParentChild(aIter - pConnectionList->begin()));
|
2011-09-29 23:02:56 +01:00
|
|
|
aRelations.push_back(xInterface);
|
|
|
|
}
|
2002-02-06 07:55:08 +00:00
|
|
|
|
2004-09-08 15:31:25 +00:00
|
|
|
Reference<XInterface> *pRelations = aRelations.empty() ? 0 : &aRelations[0];
|
|
|
|
Sequence< Reference<XInterface> > aSeq(pRelations, aRelations.size());
|
2002-02-06 07:55:08 +00:00
|
|
|
return AccessibleRelation(AccessibleRelationType::CONTROLLER_FOR,aSeq);
|
|
|
|
}
|
|
|
|
return AccessibleRelation();
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
sal_Bool OTableWindowAccess::isEditable() const
|
|
|
|
{
|
2008-06-25 11:54:35 +00:00
|
|
|
return m_pTable && !m_pTable->getTableView()->getDesignView()->getController().isReadOnly();
|
2002-02-08 08:10:00 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL OTableWindowAccess::getTitledBorderText( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
return getAccessibleName( );
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL OTableWindowAccess::getAccessibleName( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
::rtl::OUString sAccessibleName;
|
|
|
|
if ( m_pTable )
|
|
|
|
sAccessibleName = m_pTable->getTitle();
|
|
|
|
return sAccessibleName;
|
2002-02-06 07:55:08 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
2003-06-25 10:05:09 +00:00
|
|
|
Reference< XAccessibleContext > SAL_CALL OTableWindowAccess::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2002-02-06 07:55:08 +00:00
|
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
2010-10-12 15:59:03 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|