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