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