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 : // -----------------------------------------------------------------------------
41 0 : ::rtl::OUString SAL_CALL OJoinDesignViewAccess::getImplementationName() throw(RuntimeException)
42 : {
43 0 : return getImplementationName_Static();
44 : }
45 : // -----------------------------------------------------------------------------
46 0 : ::rtl::OUString OJoinDesignViewAccess::getImplementationName_Static(void) throw( RuntimeException )
47 : {
48 0 : return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.comp.dbu.JoinViewAccessibility"));
49 : }
50 : // -----------------------------------------------------------------------------
51 0 : void OJoinDesignViewAccess::clearTableView()
52 : {
53 0 : ::osl::MutexGuard aGuard( m_aMutex );
54 0 : m_pTableView = NULL;
55 0 : }
56 : // -----------------------------------------------------------------------------
57 : // XAccessibleContext
58 0 : sal_Int32 SAL_CALL OJoinDesignViewAccess::getAccessibleChildCount( ) throw (RuntimeException)
59 : {
60 : // TODO may be this will change to only visible windows
61 : // this is the same assumption mt implements
62 0 : ::osl::MutexGuard aGuard( m_aMutex );
63 0 : sal_Int32 nChildCount = 0;
64 0 : if ( m_pTableView )
65 0 : nChildCount = m_pTableView->GetTabWinCount() + m_pTableView->getTableConnections()->size();
66 0 : return nChildCount;
67 : }
68 : // -----------------------------------------------------------------------------
69 0 : Reference< XAccessible > SAL_CALL OJoinDesignViewAccess::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException,RuntimeException)
70 : {
71 0 : Reference< XAccessible > aRet;
72 0 : ::osl::MutexGuard aGuard( m_aMutex );
73 0 : if(i >= 0 && i < getAccessibleChildCount() && m_pTableView )
74 : {
75 : // check if we should return a table window or a connection
76 0 : sal_Int32 nTableWindowCount = m_pTableView->GetTabWinCount();
77 0 : if( i < nTableWindowCount )
78 : {
79 0 : OJoinTableView::OTableWindowMap::iterator aIter = m_pTableView->GetTabWinMap()->begin();
80 0 : for (sal_Int32 j=i; j; ++aIter,--j)
81 : ;
82 0 : aRet = aIter->second->GetAccessible();
83 : }
84 0 : else if( size_t(i - nTableWindowCount) < m_pTableView->getTableConnections()->size() )
85 0 : aRet = (*m_pTableView->getTableConnections())[i - nTableWindowCount]->GetAccessible();
86 : }
87 : else
88 0 : throw IndexOutOfBoundsException();
89 0 : return aRet;
90 : }
91 : // -----------------------------------------------------------------------------
92 0 : sal_Bool OJoinDesignViewAccess::isEditable() const
93 : {
94 0 : return m_pTableView && !m_pTableView->getDesignView()->getController().isReadOnly();
95 : }
96 : // -----------------------------------------------------------------------------
97 0 : sal_Int16 SAL_CALL OJoinDesignViewAccess::getAccessibleRole( ) throw (RuntimeException)
98 : {
99 0 : return AccessibleRole::VIEW_PORT;
100 : }
101 : // -----------------------------------------------------------------------------
102 0 : Reference< XAccessibleContext > SAL_CALL OJoinDesignViewAccess::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException)
103 : {
104 0 : return this;
105 : }
106 : // -----------------------------------------------------------------------------
107 : // -----------------------------------------------------------------------------
108 : // XInterface
109 : // -----------------------------------------------------------------------------
110 0 : IMPLEMENT_FORWARD_XINTERFACE2( OJoinDesignViewAccess, VCLXAccessibleComponent, OJoinDesignViewAccess_BASE )
111 : // -----------------------------------------------------------------------------
112 : // XTypeProvider
113 : // -----------------------------------------------------------------------------
114 0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( OJoinDesignViewAccess, VCLXAccessibleComponent, OJoinDesignViewAccess_BASE )
115 : }
116 :
117 : // -----------------------------------------------------------------------------
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|