1*96de5490SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*96de5490SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*96de5490SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*96de5490SAndrew Rist * distributed with this work for additional information 6*96de5490SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*96de5490SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*96de5490SAndrew Rist * "License"); you may not use this file except in compliance 9*96de5490SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*96de5490SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*96de5490SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*96de5490SAndrew Rist * software distributed under the License is distributed on an 15*96de5490SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*96de5490SAndrew Rist * KIND, either express or implied. See the License for the 17*96de5490SAndrew Rist * specific language governing permissions and limitations 18*96de5490SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*96de5490SAndrew Rist *************************************************************/ 21*96de5490SAndrew Rist 22*96de5490SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx" 26cdf0e10cSrcweir #ifndef DBACCESS_JACCESS_HXX 27cdf0e10cSrcweir #include "JAccess.hxx" 28cdf0e10cSrcweir #endif 29cdf0e10cSrcweir #ifndef DBAUI_JOINTABLEVIEW_HXX 30cdf0e10cSrcweir #include "JoinTableView.hxx" 31cdf0e10cSrcweir #endif 32cdf0e10cSrcweir #ifndef DBAUI_JOINTABLEVIEW_HXX 33cdf0e10cSrcweir #include "JoinTableView.hxx" 34cdf0e10cSrcweir #endif 35cdf0e10cSrcweir #ifndef DBAUI_TABLEWINDOW_HXX 36cdf0e10cSrcweir #include "TableWindow.hxx" 37cdf0e10cSrcweir #endif 38cdf0e10cSrcweir #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_ 39cdf0e10cSrcweir #include <com/sun/star/accessibility/AccessibleRole.hpp> 40cdf0e10cSrcweir #endif 41cdf0e10cSrcweir #ifndef DBAUI_JOINDESIGNVIEW_HXX 42cdf0e10cSrcweir #include "JoinDesignView.hxx" 43cdf0e10cSrcweir #endif 44cdf0e10cSrcweir #ifndef DBAUI_JOINCONTROLLER_HXX 45cdf0e10cSrcweir #include "JoinController.hxx" 46cdf0e10cSrcweir #endif 47cdf0e10cSrcweir #ifndef DBAUI_TABLECONNECTION_HXX 48cdf0e10cSrcweir #include "TableConnection.hxx" 49cdf0e10cSrcweir #endif 50cdf0e10cSrcweir 51cdf0e10cSrcweir namespace dbaui 52cdf0e10cSrcweir { 53cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 54cdf0e10cSrcweir using namespace ::com::sun::star::uno; 55cdf0e10cSrcweir using namespace ::com::sun::star::beans; 56cdf0e10cSrcweir using namespace ::com::sun::star::lang; 57cdf0e10cSrcweir OJoinDesignViewAccess(OJoinTableView * _pTableView)58cdf0e10cSrcweir OJoinDesignViewAccess::OJoinDesignViewAccess(OJoinTableView* _pTableView) 59cdf0e10cSrcweir :VCLXAccessibleComponent(_pTableView->GetComponentInterface().is() ? _pTableView->GetWindowPeer() : NULL) 60cdf0e10cSrcweir ,m_pTableView(_pTableView) 61cdf0e10cSrcweir { 62cdf0e10cSrcweir } 63cdf0e10cSrcweir // ----------------------------------------------------------------------------- getImplementationName()64cdf0e10cSrcweir ::rtl::OUString SAL_CALL OJoinDesignViewAccess::getImplementationName() throw(RuntimeException) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir return getImplementationName_Static(); 67cdf0e10cSrcweir } 68cdf0e10cSrcweir // ----------------------------------------------------------------------------- getImplementationName_Static(void)69cdf0e10cSrcweir ::rtl::OUString OJoinDesignViewAccess::getImplementationName_Static(void) throw( RuntimeException ) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.JoinViewAccessibility"); 72cdf0e10cSrcweir } 73cdf0e10cSrcweir // ----------------------------------------------------------------------------- clearTableView()74cdf0e10cSrcweir void OJoinDesignViewAccess::clearTableView() 75cdf0e10cSrcweir { 76cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 77cdf0e10cSrcweir m_pTableView = NULL; 78cdf0e10cSrcweir } 79cdf0e10cSrcweir // ----------------------------------------------------------------------------- 80cdf0e10cSrcweir // XAccessibleContext getAccessibleChildCount()81cdf0e10cSrcweir sal_Int32 SAL_CALL OJoinDesignViewAccess::getAccessibleChildCount( ) throw (RuntimeException) 82cdf0e10cSrcweir { 83cdf0e10cSrcweir // TODO may be this will change to only visible windows 84cdf0e10cSrcweir // this is the same assumption mt implements 85cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 86cdf0e10cSrcweir sal_Int32 nChildCount = 0; 87cdf0e10cSrcweir if ( m_pTableView ) 88cdf0e10cSrcweir nChildCount = m_pTableView->GetTabWinCount() + m_pTableView->getTableConnections()->size(); 89cdf0e10cSrcweir return nChildCount; 90cdf0e10cSrcweir } 91cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleChild(sal_Int32 i)92cdf0e10cSrcweir Reference< XAccessible > SAL_CALL OJoinDesignViewAccess::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException,RuntimeException) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir Reference< XAccessible > aRet; 95cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 96cdf0e10cSrcweir if(i >= 0 && i < getAccessibleChildCount() && m_pTableView ) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir // check if we should return a table window or a connection 99cdf0e10cSrcweir sal_Int32 nTableWindowCount = m_pTableView->GetTabWinCount(); 100cdf0e10cSrcweir if( i < nTableWindowCount ) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir OJoinTableView::OTableWindowMap::iterator aIter = m_pTableView->GetTabWinMap()->begin(); 103cdf0e10cSrcweir for (sal_Int32 j=i; j; ++aIter,--j) 104cdf0e10cSrcweir ; 105cdf0e10cSrcweir aRet = aIter->second->GetAccessible(); 106cdf0e10cSrcweir } 107cdf0e10cSrcweir else if( size_t(i - nTableWindowCount) < m_pTableView->getTableConnections()->size() ) 108cdf0e10cSrcweir aRet = (*m_pTableView->getTableConnections())[i - nTableWindowCount]->GetAccessible(); 109cdf0e10cSrcweir } 110cdf0e10cSrcweir else 111cdf0e10cSrcweir throw IndexOutOfBoundsException(); 112cdf0e10cSrcweir return aRet; 113cdf0e10cSrcweir } 114cdf0e10cSrcweir // ----------------------------------------------------------------------------- isEditable() const115cdf0e10cSrcweir sal_Bool OJoinDesignViewAccess::isEditable() const 116cdf0e10cSrcweir { 117cdf0e10cSrcweir return m_pTableView && !m_pTableView->getDesignView()->getController().isReadOnly(); 118cdf0e10cSrcweir } 119cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleRole()120cdf0e10cSrcweir sal_Int16 SAL_CALL OJoinDesignViewAccess::getAccessibleRole( ) throw (RuntimeException) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir return AccessibleRole::VIEW_PORT; 123cdf0e10cSrcweir } 124cdf0e10cSrcweir // ----------------------------------------------------------------------------- getAccessibleContext()125cdf0e10cSrcweir Reference< XAccessibleContext > SAL_CALL OJoinDesignViewAccess::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir return this; 128cdf0e10cSrcweir } 129cdf0e10cSrcweir // ----------------------------------------------------------------------------- 130cdf0e10cSrcweir // ----------------------------------------------------------------------------- 131cdf0e10cSrcweir // XInterface 132cdf0e10cSrcweir // ----------------------------------------------------------------------------- 133cdf0e10cSrcweir IMPLEMENT_FORWARD_XINTERFACE2( OJoinDesignViewAccess, VCLXAccessibleComponent, OJoinDesignViewAccess_BASE ) 134cdf0e10cSrcweir // ----------------------------------------------------------------------------- 135cdf0e10cSrcweir // XTypeProvider 136cdf0e10cSrcweir // ----------------------------------------------------------------------------- 137cdf0e10cSrcweir IMPLEMENT_FORWARD_XTYPEPROVIDER2( OJoinDesignViewAccess, VCLXAccessibleComponent, OJoinDesignViewAccess_BASE ) 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir // ----------------------------------------------------------------------------- 141cdf0e10cSrcweir 142