Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "JAccess.hxx"
21 : #include "JoinTableView.hxx"
22 : #include "TableWindow.hxx"
23 : #include <com/sun/star/accessibility/AccessibleRole.hpp>
24 : #include "JoinDesignView.hxx"
25 : #include "JoinController.hxx"
26 : #include "TableConnection.hxx"
27 :
28 : namespace dbaui
29 : {
30 : using namespace ::com::sun::star::accessibility;
31 : using namespace ::com::sun::star::uno;
32 : using namespace ::com::sun::star::beans;
33 : using namespace ::com::sun::star::lang;
34 :
35 0 : OJoinDesignViewAccess::OJoinDesignViewAccess(OJoinTableView* _pTableView)
36 0 : :VCLXAccessibleComponent(_pTableView->GetComponentInterface().is() ? _pTableView->GetWindowPeer() : NULL)
37 0 : ,m_pTableView(_pTableView)
38 : {
39 0 : }
40 0 : OUString SAL_CALL OJoinDesignViewAccess::getImplementationName() throw(RuntimeException, std::exception)
41 : {
42 0 : return getImplementationName_Static();
43 : }
44 0 : OUString OJoinDesignViewAccess::getImplementationName_Static(void) throw( RuntimeException )
45 : {
46 0 : return OUString("org.openoffice.comp.dbu.JoinViewAccessibility");
47 : }
48 0 : void OJoinDesignViewAccess::clearTableView()
49 : {
50 0 : ::osl::MutexGuard aGuard( m_aMutex );
51 0 : m_pTableView = NULL;
52 0 : }
53 : // XAccessibleContext
54 0 : sal_Int32 SAL_CALL OJoinDesignViewAccess::getAccessibleChildCount( ) throw (RuntimeException, std::exception)
55 : {
56 : // TODO may be this will change to only visible windows
57 : // this is the same assumption mt implements
58 0 : ::osl::MutexGuard aGuard( m_aMutex );
59 0 : sal_Int32 nChildCount = 0;
60 0 : if ( m_pTableView )
61 0 : nChildCount = m_pTableView->GetTabWinCount() + m_pTableView->getTableConnections()->size();
62 0 : return nChildCount;
63 : }
64 0 : Reference< XAccessible > SAL_CALL OJoinDesignViewAccess::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException,RuntimeException, std::exception)
65 : {
66 0 : Reference< XAccessible > aRet;
67 0 : ::osl::MutexGuard aGuard( m_aMutex );
68 0 : if(i >= 0 && i < getAccessibleChildCount() && m_pTableView )
69 : {
70 : // check if we should return a table window or a connection
71 0 : sal_Int32 nTableWindowCount = m_pTableView->GetTabWinCount();
72 0 : if( i < nTableWindowCount )
73 : {
74 0 : OJoinTableView::OTableWindowMap::iterator aIter = m_pTableView->GetTabWinMap()->begin();
75 0 : for (sal_Int32 j=i; j; ++aIter,--j)
76 : ;
77 0 : aRet = aIter->second->GetAccessible();
78 : }
79 0 : else if( size_t(i - nTableWindowCount) < m_pTableView->getTableConnections()->size() )
80 0 : aRet = (*m_pTableView->getTableConnections())[i - nTableWindowCount]->GetAccessible();
81 : }
82 : else
83 0 : throw IndexOutOfBoundsException();
84 0 : return aRet;
85 : }
86 0 : sal_Bool OJoinDesignViewAccess::isEditable() const
87 : {
88 0 : return m_pTableView && !m_pTableView->getDesignView()->getController().isReadOnly();
89 : }
90 0 : sal_Int16 SAL_CALL OJoinDesignViewAccess::getAccessibleRole( ) throw (RuntimeException, std::exception)
91 : {
92 0 : return AccessibleRole::VIEW_PORT;
93 : }
94 0 : Reference< XAccessibleContext > SAL_CALL OJoinDesignViewAccess::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
95 : {
96 0 : return this;
97 : }
98 : // XInterface
99 0 : IMPLEMENT_FORWARD_XINTERFACE2( OJoinDesignViewAccess, VCLXAccessibleComponent, OJoinDesignViewAccess_BASE )
100 : // XTypeProvider
101 0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( OJoinDesignViewAccess, VCLXAccessibleComponent, OJoinDesignViewAccess_BASE )
102 : }
103 :
104 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|