update dev300-m58
[ooovba.git] / dbaccess / source / ui / querydesign / JAccess.cxx
bloba62b1911d2fa17178cc02140d0f7eea44a69655e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: JAccess.cxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dbaccess.hxx"
33 #ifndef DBACCESS_JACCESS_HXX
34 #include "JAccess.hxx"
35 #endif
36 #ifndef DBAUI_JOINTABLEVIEW_HXX
37 #include "JoinTableView.hxx"
38 #endif
39 #ifndef DBAUI_JOINTABLEVIEW_HXX
40 #include "JoinTableView.hxx"
41 #endif
42 #ifndef DBAUI_TABLEWINDOW_HXX
43 #include "TableWindow.hxx"
44 #endif
45 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
46 #include <com/sun/star/accessibility/AccessibleRole.hpp>
47 #endif
48 #ifndef DBAUI_JOINDESIGNVIEW_HXX
49 #include "JoinDesignView.hxx"
50 #endif
51 #ifndef DBAUI_JOINCONTROLLER_HXX
52 #include "JoinController.hxx"
53 #endif
54 #ifndef DBAUI_TABLECONNECTION_HXX
55 #include "TableConnection.hxx"
56 #endif
58 namespace dbaui
60 using namespace ::com::sun::star::accessibility;
61 using namespace ::com::sun::star::uno;
62 using namespace ::com::sun::star::beans;
63 using namespace ::com::sun::star::lang;
65 OJoinDesignViewAccess::OJoinDesignViewAccess(OJoinTableView* _pTableView)
66 :VCLXAccessibleComponent(_pTableView->GetComponentInterface().is() ? _pTableView->GetWindowPeer() : NULL)
67 ,m_pTableView(_pTableView)
70 // -----------------------------------------------------------------------------
71 ::rtl::OUString SAL_CALL OJoinDesignViewAccess::getImplementationName() throw(RuntimeException)
73 return getImplementationName_Static();
75 // -----------------------------------------------------------------------------
76 ::rtl::OUString OJoinDesignViewAccess::getImplementationName_Static(void) throw( RuntimeException )
78 return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbu.JoinViewAccessibility");
80 // -----------------------------------------------------------------------------
81 void OJoinDesignViewAccess::clearTableView()
83 ::osl::MutexGuard aGuard( m_aMutex );
84 m_pTableView = NULL;
86 // -----------------------------------------------------------------------------
87 // XAccessibleContext
88 sal_Int32 SAL_CALL OJoinDesignViewAccess::getAccessibleChildCount( ) throw (RuntimeException)
90 // TODO may be this will change to only visible windows
91 // this is the same assumption mt implements
92 ::osl::MutexGuard aGuard( m_aMutex );
93 sal_Int32 nChildCount = 0;
94 if ( m_pTableView )
95 nChildCount = m_pTableView->GetTabWinCount() + m_pTableView->getTableConnections()->size();
96 return nChildCount;
98 // -----------------------------------------------------------------------------
99 Reference< XAccessible > SAL_CALL OJoinDesignViewAccess::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException,RuntimeException)
101 Reference< XAccessible > aRet;
102 ::osl::MutexGuard aGuard( m_aMutex );
103 if(i >= 0 && i < getAccessibleChildCount() && m_pTableView )
105 // check if we should return a table window or a connection
106 sal_Int32 nTableWindowCount = m_pTableView->GetTabWinCount();
107 if( i < nTableWindowCount )
109 OJoinTableView::OTableWindowMap::iterator aIter = m_pTableView->GetTabWinMap()->begin();
110 for (sal_Int32 j=i; j; ++aIter,--j)
112 aRet = aIter->second->GetAccessible();
114 else if( size_t(i - nTableWindowCount) < m_pTableView->getTableConnections()->size() )
115 aRet = (*m_pTableView->getTableConnections())[i - nTableWindowCount]->GetAccessible();
117 else
118 throw IndexOutOfBoundsException();
119 return aRet;
121 // -----------------------------------------------------------------------------
122 sal_Bool OJoinDesignViewAccess::isEditable() const
124 return m_pTableView && !m_pTableView->getDesignView()->getController().isReadOnly();
126 // -----------------------------------------------------------------------------
127 sal_Int16 SAL_CALL OJoinDesignViewAccess::getAccessibleRole( ) throw (RuntimeException)
129 return AccessibleRole::VIEW_PORT;
131 // -----------------------------------------------------------------------------
132 Reference< XAccessibleContext > SAL_CALL OJoinDesignViewAccess::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException)
134 return this;
136 // -----------------------------------------------------------------------------
137 // -----------------------------------------------------------------------------
138 // XInterface
139 // -----------------------------------------------------------------------------
140 IMPLEMENT_FORWARD_XINTERFACE2( OJoinDesignViewAccess, VCLXAccessibleComponent, OJoinDesignViewAccess_BASE )
141 // -----------------------------------------------------------------------------
142 // XTypeProvider
143 // -----------------------------------------------------------------------------
144 IMPLEMENT_FORWARD_XTYPEPROVIDER2( OJoinDesignViewAccess, VCLXAccessibleComponent, OJoinDesignViewAccess_BASE )
147 // -----------------------------------------------------------------------------