1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <JAccess.hxx>
21 #include <JoinTableView.hxx>
22 #include <TableWindow.hxx>
23 #include <com/sun/star/accessibility/AccessibleRole.hpp>
24 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
25 #include <TableConnection.hxx>
26 #include <o3tl/safeint.hxx>
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
;
35 OJoinDesignViewAccess::OJoinDesignViewAccess(OJoinTableView
* _pTableView
)
36 :ImplInheritanceHelper(_pTableView
->GetComponentInterface().is() ? _pTableView
->GetWindowPeer() : nullptr)
37 ,m_pTableView(_pTableView
)
40 OUString SAL_CALL
OJoinDesignViewAccess::getImplementationName()
42 return "org.openoffice.comp.dbu.JoinViewAccessibility";
44 void OJoinDesignViewAccess::clearTableView()
46 ::osl::MutexGuard
aGuard( m_aMutex
);
47 m_pTableView
= nullptr;
50 sal_Int64 SAL_CALL
OJoinDesignViewAccess::getAccessibleChildCount( )
52 // TODO may be this will change to only visible windows
53 // this is the same assumption mt implements
54 ::osl::MutexGuard
aGuard( m_aMutex
);
55 sal_Int64 nChildCount
= 0;
57 nChildCount
= m_pTableView
->GetTabWinCount() + m_pTableView
->getTableConnections().size();
60 Reference
< XAccessible
> SAL_CALL
OJoinDesignViewAccess::getAccessibleChild( sal_Int64 i
)
62 Reference
< XAccessible
> aRet
;
63 ::osl::MutexGuard
aGuard( m_aMutex
);
64 if(i
< 0 || i
>= getAccessibleChildCount() || !m_pTableView
)
65 throw IndexOutOfBoundsException();
66 // check if we should return a table window or a connection
67 sal_Int64 nTableWindowCount
= m_pTableView
->GetTabWinCount();
68 if( i
< nTableWindowCount
)
70 OJoinTableView::OTableWindowMap::const_iterator aIter
= std::next(m_pTableView
->GetTabWinMap().begin(), i
);
71 aRet
= aIter
->second
->GetAccessible();
73 else if( o3tl::make_unsigned(i
- nTableWindowCount
) < m_pTableView
->getTableConnections().size() )
74 aRet
= m_pTableView
->getTableConnections()[i
- nTableWindowCount
]->GetAccessible();
77 sal_Int16 SAL_CALL
OJoinDesignViewAccess::getAccessibleRole( )
79 return AccessibleRole::VIEW_PORT
;
81 Reference
< XAccessibleContext
> SAL_CALL
OJoinDesignViewAccess::getAccessibleContext( )
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */