1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 30*cdf0e10cSrcweir #ifndef DBACCESS_TABLEWINDOWACCESS_HXX 31*cdf0e10cSrcweir #include "TableWindowAccess.hxx" 32*cdf0e10cSrcweir #endif 33*cdf0e10cSrcweir #ifndef DBACCESS_JACCESS_HXX 34*cdf0e10cSrcweir #include "JAccess.hxx" 35*cdf0e10cSrcweir #endif 36*cdf0e10cSrcweir #ifndef DBAUI_TABLEWINDOW_HXX 37*cdf0e10cSrcweir #include "TableWindow.hxx" 38*cdf0e10cSrcweir #endif 39*cdf0e10cSrcweir #ifndef DBAUI_TABLEWINDOWLISTBOX_HXX 40*cdf0e10cSrcweir #include "TableWindowListBox.hxx" 41*cdf0e10cSrcweir #endif 42*cdf0e10cSrcweir #ifndef DBAUI_JOINDESIGNVIEW_HXX 43*cdf0e10cSrcweir #include "JoinDesignView.hxx" 44*cdf0e10cSrcweir #endif 45*cdf0e10cSrcweir #ifndef DBAUI_JOINCONTROLLER_HXX 46*cdf0e10cSrcweir #include "JoinController.hxx" 47*cdf0e10cSrcweir #endif 48*cdf0e10cSrcweir #ifndef DBAUI_JOINTABLEVIEW_HXX 49*cdf0e10cSrcweir #include "JoinTableView.hxx" 50*cdf0e10cSrcweir #endif 51*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_ 52*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 53*cdf0e10cSrcweir #endif 54*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLERELATIONTYPE_HPP_ 55*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRelationType.hpp> 56*cdf0e10cSrcweir #endif 57*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_ 58*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleStateType.hpp> 59*cdf0e10cSrcweir #endif 60*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_ 61*cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleEventId.hpp> 62*cdf0e10cSrcweir #endif 63*cdf0e10cSrcweir #ifndef _COMPHELPER_SEQUENCE_HXX_ 64*cdf0e10cSrcweir #include <comphelper/sequence.hxx> 65*cdf0e10cSrcweir #endif 66*cdf0e10cSrcweir #ifndef _DBU_QRY_HRC_ 67*cdf0e10cSrcweir #include "dbu_qry.hrc" 68*cdf0e10cSrcweir #endif 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir namespace dbaui 72*cdf0e10cSrcweir { 73*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 74*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 75*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 76*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 77*cdf0e10cSrcweir // using namespace ::com::sun::star::awt; 78*cdf0e10cSrcweir using namespace ::com::sun::star; 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir OTableWindowAccess::OTableWindowAccess(OTableWindow* _pTable) 81*cdf0e10cSrcweir :VCLXAccessibleComponent(_pTable->GetComponentInterface().is() ? _pTable->GetWindowPeer() : NULL) 82*cdf0e10cSrcweir ,m_pTable(_pTable) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir } 85*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 86*cdf0e10cSrcweir void SAL_CALL OTableWindowAccess::disposing() 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir m_pTable = NULL; 89*cdf0e10cSrcweir VCLXAccessibleComponent::disposing(); 90*cdf0e10cSrcweir } 91*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 92*cdf0e10cSrcweir void OTableWindowAccess::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir if ( rVclWindowEvent.GetId() == VCLEVENT_OBJECT_DYING ) 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 97*cdf0e10cSrcweir m_pTable = NULL; 98*cdf0e10cSrcweir } 99*cdf0e10cSrcweir 100*cdf0e10cSrcweir VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent ); 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 103*cdf0e10cSrcweir Any SAL_CALL OTableWindowAccess::queryInterface( const Type& aType ) throw (RuntimeException) 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir Any aRet(VCLXAccessibleComponent::queryInterface( aType )); 106*cdf0e10cSrcweir return aRet.hasValue() ? aRet : OTableWindowAccess_BASE::queryInterface( aType ); 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 109*cdf0e10cSrcweir Sequence< Type > SAL_CALL OTableWindowAccess::getTypes( ) throw (RuntimeException) 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir return ::comphelper::concatSequences(VCLXAccessibleComponent::getTypes(),OTableWindowAccess_BASE::getTypes()); 112*cdf0e10cSrcweir } 113*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 114*cdf0e10cSrcweir ::rtl::OUString SAL_CALL OTableWindowAccess::getImplementationName() throw(RuntimeException) 115*cdf0e10cSrcweir { 116*cdf0e10cSrcweir return getImplementationName_Static(); 117*cdf0e10cSrcweir } 118*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 119*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL OTableWindowAccess::getSupportedServiceNames() throw(RuntimeException) 120*cdf0e10cSrcweir { 121*cdf0e10cSrcweir return getSupportedServiceNames_Static(); 122*cdf0e10cSrcweir } 123*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 124*cdf0e10cSrcweir // XServiceInfo - static methods 125*cdf0e10cSrcweir Sequence< ::rtl::OUString > OTableWindowAccess::getSupportedServiceNames_Static(void) throw( RuntimeException ) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir Sequence< ::rtl::OUString > aSupported(2); 128*cdf0e10cSrcweir aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.accessibility.Accessible"); 129*cdf0e10cSrcweir aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.accessibility.AccessibleContext"); 130*cdf0e10cSrcweir return aSupported; 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 133*cdf0e10cSrcweir ::rtl::OUString OTableWindowAccess::getImplementationName_Static(void) throw( RuntimeException ) 134*cdf0e10cSrcweir { 135*cdf0e10cSrcweir return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.TableWindowAccessibility"); 136*cdf0e10cSrcweir } 137*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 138*cdf0e10cSrcweir // XAccessibleContext 139*cdf0e10cSrcweir sal_Int32 SAL_CALL OTableWindowAccess::getAccessibleChildCount( ) throw (RuntimeException) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 142*cdf0e10cSrcweir sal_Int32 nCount = 0; 143*cdf0e10cSrcweir if(m_pTable) 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir if(m_pTable->GetTitleCtrl()) 146*cdf0e10cSrcweir ++nCount; 147*cdf0e10cSrcweir if(m_pTable->GetListBox()) 148*cdf0e10cSrcweir ++nCount; 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir return nCount; 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 153*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL OTableWindowAccess::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException,RuntimeException) 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 156*cdf0e10cSrcweir Reference< XAccessible > aRet; 157*cdf0e10cSrcweir if(m_pTable) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir switch(i) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir case 0: 162*cdf0e10cSrcweir if(m_pTable->GetTitleCtrl()) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir aRet = m_pTable->GetTitleCtrl()->GetAccessible(); 165*cdf0e10cSrcweir break; 166*cdf0e10cSrcweir } // fall through if title control does not exist 167*cdf0e10cSrcweir case 1: 168*cdf0e10cSrcweir if(m_pTable->GetListBox()) 169*cdf0e10cSrcweir aRet = m_pTable->GetListBox()->GetAccessible(); 170*cdf0e10cSrcweir break; 171*cdf0e10cSrcweir default: 172*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir return aRet; 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 178*cdf0e10cSrcweir sal_Int32 SAL_CALL OTableWindowAccess::getAccessibleIndexInParent( ) throw (RuntimeException) 179*cdf0e10cSrcweir { 180*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 181*cdf0e10cSrcweir sal_Int32 nIndex = -1; 182*cdf0e10cSrcweir if( m_pTable ) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir // search the postion of our table window in the table window map 185*cdf0e10cSrcweir OJoinTableView::OTableWindowMap* pMap = m_pTable->getTableView()->GetTabWinMap(); 186*cdf0e10cSrcweir OJoinTableView::OTableWindowMap::iterator aIter = pMap->begin(); 187*cdf0e10cSrcweir OJoinTableView::OTableWindowMap::iterator aEnd = pMap->end(); 188*cdf0e10cSrcweir for (nIndex = 0; aIter != aEnd && aIter->second != m_pTable; ++nIndex,++aIter) 189*cdf0e10cSrcweir ; 190*cdf0e10cSrcweir nIndex = aIter != aEnd ? nIndex : -1; 191*cdf0e10cSrcweir } 192*cdf0e10cSrcweir return nIndex; 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 195*cdf0e10cSrcweir sal_Int16 SAL_CALL OTableWindowAccess::getAccessibleRole( ) throw (RuntimeException) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir return AccessibleRole::PANEL; // ? or may be an AccessibleRole::WINDOW 198*cdf0e10cSrcweir } 199*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 200*cdf0e10cSrcweir Reference< XAccessibleRelationSet > SAL_CALL OTableWindowAccess::getAccessibleRelationSet( ) throw (RuntimeException) 201*cdf0e10cSrcweir { 202*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 203*cdf0e10cSrcweir return this; 204*cdf0e10cSrcweir } 205*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 206*cdf0e10cSrcweir // XAccessibleComponent 207*cdf0e10cSrcweir Reference< XAccessible > SAL_CALL OTableWindowAccess::getAccessibleAtPoint( const awt::Point& _aPoint ) throw (RuntimeException) 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 210*cdf0e10cSrcweir Reference< XAccessible > aRet; 211*cdf0e10cSrcweir if( m_pTable ) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir Point aPoint(_aPoint.X,_aPoint.Y); 214*cdf0e10cSrcweir Rectangle aRect(m_pTable->GetDesktopRectPixel()); 215*cdf0e10cSrcweir if( aRect.IsInside(aPoint) ) 216*cdf0e10cSrcweir aRet = this; 217*cdf0e10cSrcweir else if( m_pTable->GetListBox()->GetDesktopRectPixel().IsInside(aPoint)) 218*cdf0e10cSrcweir aRet = m_pTable->GetListBox()->GetAccessible(); 219*cdf0e10cSrcweir } 220*cdf0e10cSrcweir return aRet; 221*cdf0e10cSrcweir } 222*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 223*cdf0e10cSrcweir Reference< XAccessible > OTableWindowAccess::getParentChild(sal_Int32 _nIndex) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir Reference< XAccessible > xReturn; 226*cdf0e10cSrcweir Reference< XAccessible > xParent = getAccessibleParent(); 227*cdf0e10cSrcweir if ( xParent.is() ) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext(); 230*cdf0e10cSrcweir if ( xParentContext.is() ) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir xReturn = xParentContext->getAccessibleChild(_nIndex); 233*cdf0e10cSrcweir } 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir return xReturn; 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 238*cdf0e10cSrcweir 239*cdf0e10cSrcweir sal_Int32 SAL_CALL OTableWindowAccess::getRelationCount( ) throw (RuntimeException) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 242*cdf0e10cSrcweir return m_pTable ? m_pTable->getTableView()->getConnectionCount(m_pTable) : sal_Int32(0); 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 245*cdf0e10cSrcweir AccessibleRelation SAL_CALL OTableWindowAccess::getRelation( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 248*cdf0e10cSrcweir if( nIndex < 0 || nIndex >= getRelationCount() ) 249*cdf0e10cSrcweir throw IndexOutOfBoundsException(); 250*cdf0e10cSrcweir 251*cdf0e10cSrcweir AccessibleRelation aRet; 252*cdf0e10cSrcweir if( m_pTable ) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir OJoinTableView* pView = m_pTable->getTableView(); 255*cdf0e10cSrcweir ::std::vector<OTableConnection*>::const_iterator aIter = pView->getTableConnections(m_pTable) + nIndex; 256*cdf0e10cSrcweir aRet.TargetSet.realloc(1); 257*cdf0e10cSrcweir aRet.TargetSet[0] = getParentChild(aIter - pView->getTableConnections()->begin()); 258*cdf0e10cSrcweir aRet.RelationType = AccessibleRelationType::CONTROLLER_FOR; 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir return aRet; 261*cdf0e10cSrcweir } 262*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 263*cdf0e10cSrcweir sal_Bool SAL_CALL OTableWindowAccess::containsRelation( sal_Int16 aRelationType ) throw (RuntimeException) 264*cdf0e10cSrcweir { 265*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 266*cdf0e10cSrcweir return AccessibleRelationType::CONTROLLER_FOR == aRelationType 267*cdf0e10cSrcweir && m_pTable && m_pTable->getTableView()->ExistsAConn(m_pTable); 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 270*cdf0e10cSrcweir AccessibleRelation SAL_CALL OTableWindowAccess::getRelationByType( sal_Int16 aRelationType ) throw (RuntimeException) 271*cdf0e10cSrcweir { 272*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 273*cdf0e10cSrcweir if( AccessibleRelationType::CONTROLLER_FOR == aRelationType && m_pTable) 274*cdf0e10cSrcweir { 275*cdf0e10cSrcweir OJoinTableView* pView = m_pTable->getTableView(); 276*cdf0e10cSrcweir const ::std::vector<OTableConnection*>* pConnectionList = pView->getTableConnections(); 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir ::std::vector<OTableConnection*>::const_iterator aIter = pView->getTableConnections(m_pTable); 279*cdf0e10cSrcweir ::std::vector<OTableConnection*>::const_iterator aEnd = pConnectionList->end(); 280*cdf0e10cSrcweir ::std::vector< Reference<XInterface> > aRelations; 281*cdf0e10cSrcweir aRelations.reserve(5); // just guessing 282*cdf0e10cSrcweir for (; aIter != aEnd ; ++aIter ) 283*cdf0e10cSrcweir aRelations.push_back(getParentChild(aIter - pConnectionList->begin())); 284*cdf0e10cSrcweir 285*cdf0e10cSrcweir Reference<XInterface> *pRelations = aRelations.empty() ? 0 : &aRelations[0]; 286*cdf0e10cSrcweir Sequence< Reference<XInterface> > aSeq(pRelations, aRelations.size()); 287*cdf0e10cSrcweir return AccessibleRelation(AccessibleRelationType::CONTROLLER_FOR,aSeq); 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir return AccessibleRelation(); 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 292*cdf0e10cSrcweir sal_Bool OTableWindowAccess::isEditable() const 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir return m_pTable && !m_pTable->getTableView()->getDesignView()->getController().isReadOnly(); 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 297*cdf0e10cSrcweir ::rtl::OUString SAL_CALL OTableWindowAccess::getTitledBorderText( ) throw (RuntimeException) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir return getAccessibleName( ); 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 302*cdf0e10cSrcweir ::rtl::OUString SAL_CALL OTableWindowAccess::getAccessibleName( ) throw (RuntimeException) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 305*cdf0e10cSrcweir ::rtl::OUString sAccessibleName; 306*cdf0e10cSrcweir if ( m_pTable ) 307*cdf0e10cSrcweir sAccessibleName = m_pTable->getTitle(); 308*cdf0e10cSrcweir return sAccessibleName; 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 311*cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL OTableWindowAccess::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException) 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir return this; 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir } 318*cdf0e10cSrcweir // ----------------------------------------------------------------------------- 319*cdf0e10cSrcweir 320