fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / querydesign / TableWindowAccess.cxx
bloba2fb61435c1388e212d9491f19bb2759e6e92e03
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "TableWindowAccess.hxx"
21 #include "JAccess.hxx"
22 #include "TableWindow.hxx"
23 #include "TableWindowListBox.hxx"
24 #include "JoinDesignView.hxx"
25 #include "JoinController.hxx"
26 #include "JoinTableView.hxx"
27 #include <com/sun/star/accessibility/AccessibleRole.hpp>
28 #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
29 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
30 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
31 #include <comphelper/sequence.hxx>
32 #include "dbu_qry.hrc"
34 namespace dbaui
36 using namespace ::com::sun::star::accessibility;
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::beans;
39 using namespace ::com::sun::star::lang;
40 using namespace ::com::sun::star;
42 OTableWindowAccess::OTableWindowAccess(OTableWindow* _pTable)
43 :VCLXAccessibleComponent(_pTable->GetComponentInterface().is() ? _pTable->GetWindowPeer() : NULL)
44 ,m_pTable(_pTable)
47 void SAL_CALL OTableWindowAccess::disposing()
49 m_pTable = NULL;
50 VCLXAccessibleComponent::disposing();
52 void OTableWindowAccess::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
54 if ( rVclWindowEvent.GetId() == VCLEVENT_OBJECT_DYING )
56 ::osl::MutexGuard aGuard( m_aMutex );
57 m_pTable = NULL;
60 VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
62 Any SAL_CALL OTableWindowAccess::queryInterface( const Type& aType ) throw (RuntimeException, std::exception)
64 Any aRet(VCLXAccessibleComponent::queryInterface( aType ));
65 return aRet.hasValue() ? aRet : OTableWindowAccess_BASE::queryInterface( aType );
67 Sequence< Type > SAL_CALL OTableWindowAccess::getTypes( ) throw (RuntimeException, std::exception)
69 return ::comphelper::concatSequences(VCLXAccessibleComponent::getTypes(),OTableWindowAccess_BASE::getTypes());
71 OUString SAL_CALL OTableWindowAccess::getImplementationName() throw(RuntimeException, std::exception)
73 return getImplementationName_Static();
75 Sequence< OUString > SAL_CALL OTableWindowAccess::getSupportedServiceNames() throw(RuntimeException, std::exception)
77 return getSupportedServiceNames_Static();
79 // XServiceInfo - static methods
80 Sequence< OUString > OTableWindowAccess::getSupportedServiceNames_Static() throw( RuntimeException )
82 Sequence< OUString > aSupported(2);
83 aSupported[0] = "com.sun.star.accessibility.Accessible";
84 aSupported[1] = "com.sun.star.accessibility.AccessibleContext";
85 return aSupported;
87 OUString OTableWindowAccess::getImplementationName_Static() throw( RuntimeException )
89 return OUString("org.openoffice.comp.dbu.TableWindowAccessibility");
91 // XAccessibleContext
92 sal_Int32 SAL_CALL OTableWindowAccess::getAccessibleChildCount( ) throw (RuntimeException, std::exception)
94 ::osl::MutexGuard aGuard( m_aMutex );
95 sal_Int32 nCount = 0;
96 if(m_pTable)
98 ++nCount;
99 if(m_pTable->GetListBox())
100 ++nCount;
102 return nCount;
104 Reference< XAccessible > SAL_CALL OTableWindowAccess::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException,RuntimeException, std::exception)
106 ::osl::MutexGuard aGuard( m_aMutex );
107 Reference< XAccessible > aRet;
108 if (m_pTable && !m_pTable->IsDisposed())
110 switch(i)
112 case 0:
114 VclPtr<OTableWindowTitle> xCtrl(m_pTable->GetTitleCtrl());
115 if (xCtrl)
116 aRet = xCtrl->GetAccessible();
117 break;
119 case 1:
121 VclPtr<OTableWindowListBox> xCtrl(m_pTable->GetListBox());
122 if (xCtrl)
123 aRet = xCtrl->GetAccessible();
124 break;
126 default:
127 throw IndexOutOfBoundsException();
130 return aRet;
132 sal_Int32 SAL_CALL OTableWindowAccess::getAccessibleIndexInParent( ) throw (RuntimeException, std::exception)
134 ::osl::MutexGuard aGuard( m_aMutex );
135 sal_Int32 nIndex = -1;
136 if( m_pTable )
138 // search the position of our table window in the table window map
139 OJoinTableView::OTableWindowMap& rMap = m_pTable->getTableView()->GetTabWinMap();
140 OJoinTableView::OTableWindowMap::iterator aIter = rMap.begin();
141 OJoinTableView::OTableWindowMap::iterator aEnd = rMap.end();
142 for (nIndex = 0; aIter != aEnd && aIter->second != m_pTable; ++nIndex,++aIter)
144 nIndex = aIter != aEnd ? nIndex : -1;
146 return nIndex;
148 sal_Int16 SAL_CALL OTableWindowAccess::getAccessibleRole( ) throw (RuntimeException, std::exception)
150 return AccessibleRole::PANEL; // ? or may be an AccessibleRole::WINDOW
152 Reference< XAccessibleRelationSet > SAL_CALL OTableWindowAccess::getAccessibleRelationSet( ) throw (RuntimeException, std::exception)
154 ::osl::MutexGuard aGuard( m_aMutex );
155 return this;
157 // XAccessibleComponent
158 Reference< XAccessible > SAL_CALL OTableWindowAccess::getAccessibleAtPoint( const awt::Point& _aPoint ) throw (RuntimeException, std::exception)
160 ::osl::MutexGuard aGuard( m_aMutex );
161 Reference< XAccessible > aRet;
162 if(m_pTable && !m_pTable->IsDisposed())
164 Point aPoint(_aPoint.X,_aPoint.Y);
165 Rectangle aRect(m_pTable->GetDesktopRectPixel());
166 if( aRect.IsInside(aPoint) )
167 aRet = this;
168 else if( m_pTable->GetListBox()->GetDesktopRectPixel().IsInside(aPoint))
169 aRet = m_pTable->GetListBox()->GetAccessible();
171 return aRet;
173 Reference< XAccessible > OTableWindowAccess::getParentChild(sal_Int32 _nIndex)
175 Reference< XAccessible > xReturn;
176 Reference< XAccessible > xParent = getAccessibleParent();
177 if ( xParent.is() )
179 Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext();
180 if ( xParentContext.is() )
182 xReturn = xParentContext->getAccessibleChild(_nIndex);
185 return xReturn;
188 sal_Int32 SAL_CALL OTableWindowAccess::getRelationCount( ) throw (RuntimeException, std::exception)
190 ::osl::MutexGuard aGuard( m_aMutex );
191 return m_pTable ? m_pTable->getTableView()->getConnectionCount(m_pTable) : sal_Int32(0);
193 AccessibleRelation SAL_CALL OTableWindowAccess::getRelation( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
195 ::osl::MutexGuard aGuard( m_aMutex );
196 if( nIndex < 0 || nIndex >= getRelationCount() )
197 throw IndexOutOfBoundsException();
199 AccessibleRelation aRet;
200 if( m_pTable )
202 OJoinTableView* pView = m_pTable->getTableView();
203 auto aIter = pView->getTableConnections(m_pTable) + nIndex;
204 aRet.TargetSet.realloc(1);
205 aRet.TargetSet[0] = getParentChild(aIter - pView->getTableConnections().begin());
206 aRet.RelationType = AccessibleRelationType::CONTROLLER_FOR;
208 return aRet;
210 sal_Bool SAL_CALL OTableWindowAccess::containsRelation( sal_Int16 aRelationType ) throw (RuntimeException, std::exception)
212 ::osl::MutexGuard aGuard( m_aMutex );
213 return AccessibleRelationType::CONTROLLER_FOR == aRelationType
214 && m_pTable && m_pTable->getTableView()->ExistsAConn(m_pTable);
216 AccessibleRelation SAL_CALL OTableWindowAccess::getRelationByType( sal_Int16 aRelationType ) throw (RuntimeException, std::exception)
218 ::osl::MutexGuard aGuard( m_aMutex );
219 if( AccessibleRelationType::CONTROLLER_FOR == aRelationType && m_pTable)
221 OJoinTableView* pView = m_pTable->getTableView();
222 const auto& rConnectionList = pView->getTableConnections();
224 auto aIter = pView->getTableConnections(m_pTable);
225 auto aEnd = rConnectionList.end();
226 ::std::vector< Reference<XInterface> > aRelations;
227 aRelations.reserve(5); // just guessing
228 for (; aIter != aEnd ; ++aIter )
230 uno::Reference<uno::XInterface> xInterface(
231 getParentChild(aIter - rConnectionList.begin()));
232 aRelations.push_back(xInterface);
235 Sequence< Reference<XInterface> > aSeq(aRelations.data(), aRelations.size());
236 return AccessibleRelation(AccessibleRelationType::CONTROLLER_FOR,aSeq);
238 return AccessibleRelation();
240 OUString SAL_CALL OTableWindowAccess::getTitledBorderText( ) throw (RuntimeException, std::exception)
242 return getAccessibleName( );
244 OUString SAL_CALL OTableWindowAccess::getAccessibleName( ) throw (RuntimeException, std::exception)
246 ::osl::MutexGuard aGuard( m_aMutex );
247 OUString sAccessibleName;
248 if ( m_pTable )
249 sAccessibleName = m_pTable->getTitle();
250 return sAccessibleName;
252 Reference< XAccessibleContext > SAL_CALL OTableWindowAccess::getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException, std::exception)
254 return this;
259 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */