LCOV - code coverage report
Current view: top level - dbaccess/source/ui/querydesign - TableWindowAccess.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 129 0.8 %
Date: 2015-06-13 12:38:46 Functions: 2 25 8.0 %
Legend: Lines: hit not hit

          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 "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"
      33             : 
      34             : namespace dbaui
      35             : {
      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;
      41             : 
      42           0 :     OTableWindowAccess::OTableWindowAccess(OTableWindow* _pTable)
      43           0 :         :VCLXAccessibleComponent(_pTable->GetComponentInterface().is() ? _pTable->GetWindowPeer() : NULL)
      44           0 :         ,m_pTable(_pTable)
      45             :     {
      46           0 :     }
      47           0 :     void SAL_CALL OTableWindowAccess::disposing()
      48             :     {
      49           0 :         m_pTable = NULL;
      50           0 :         VCLXAccessibleComponent::disposing();
      51           0 :     }
      52           0 :     void OTableWindowAccess::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
      53             :     {
      54           0 :         if ( rVclWindowEvent.GetId() == VCLEVENT_OBJECT_DYING )
      55             :         {
      56           0 :             ::osl::MutexGuard aGuard( m_aMutex );
      57           0 :             m_pTable = NULL;
      58             :         }
      59             : 
      60           0 :         VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
      61           0 :     }
      62           0 :     Any SAL_CALL OTableWindowAccess::queryInterface( const Type& aType ) throw (RuntimeException, std::exception)
      63             :     {
      64           0 :         Any aRet(VCLXAccessibleComponent::queryInterface( aType ));
      65           0 :         return aRet.hasValue() ? aRet : OTableWindowAccess_BASE::queryInterface( aType );
      66             :     }
      67           0 :     Sequence< Type > SAL_CALL OTableWindowAccess::getTypes(  ) throw (RuntimeException, std::exception)
      68             :     {
      69           0 :         return ::comphelper::concatSequences(VCLXAccessibleComponent::getTypes(),OTableWindowAccess_BASE::getTypes());
      70             :     }
      71           0 :     OUString SAL_CALL OTableWindowAccess::getImplementationName() throw(RuntimeException, std::exception)
      72             :     {
      73           0 :         return getImplementationName_Static();
      74             :     }
      75           0 :     Sequence< OUString > SAL_CALL OTableWindowAccess::getSupportedServiceNames() throw(RuntimeException, std::exception)
      76             :     {
      77           0 :         return getSupportedServiceNames_Static();
      78             :     }
      79             :     // XServiceInfo - static methods
      80           0 :     Sequence< OUString > OTableWindowAccess::getSupportedServiceNames_Static() throw( RuntimeException )
      81             :     {
      82           0 :         Sequence< OUString > aSupported(2);
      83           0 :         aSupported[0] = "com.sun.star.accessibility.Accessible";
      84           0 :         aSupported[1] = "com.sun.star.accessibility.AccessibleContext";
      85           0 :         return aSupported;
      86             :     }
      87           0 :     OUString OTableWindowAccess::getImplementationName_Static() throw( RuntimeException )
      88             :     {
      89           0 :         return OUString("org.openoffice.comp.dbu.TableWindowAccessibility");
      90             :     }
      91             :     // XAccessibleContext
      92           0 :     sal_Int32 SAL_CALL OTableWindowAccess::getAccessibleChildCount(  ) throw (RuntimeException, std::exception)
      93             :     {
      94           0 :         ::osl::MutexGuard aGuard( m_aMutex );
      95           0 :         sal_Int32 nCount = 0;
      96           0 :         if(m_pTable)
      97             :         {
      98           0 :             ++nCount;
      99           0 :             if(m_pTable->GetListBox())
     100           0 :                 ++nCount;
     101             :         }
     102           0 :         return nCount;
     103             :     }
     104           0 :     Reference< XAccessible > SAL_CALL OTableWindowAccess::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException,RuntimeException, std::exception)
     105             :     {
     106           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     107           0 :         Reference< XAccessible > aRet;
     108           0 :         if(m_pTable)
     109             :         {
     110           0 :             switch(i)
     111             :             {
     112             :                 case 0:
     113           0 :                     aRet = m_pTable->GetTitleCtrl().GetAccessible();
     114           0 :                     break;
     115             :                 case 1:
     116           0 :                     aRet = m_pTable->GetListBox()->GetAccessible();
     117           0 :                     break;
     118             :                 default:
     119           0 :                     throw IndexOutOfBoundsException();
     120             :             }
     121             :         }
     122           0 :         return aRet;
     123             :     }
     124           0 :     sal_Int32 SAL_CALL OTableWindowAccess::getAccessibleIndexInParent(  ) throw (RuntimeException, std::exception)
     125             :     {
     126           0 :         ::osl::MutexGuard aGuard( m_aMutex  );
     127           0 :         sal_Int32 nIndex = -1;
     128           0 :         if( m_pTable )
     129             :         {
     130             :             // search the position of our table window in the table window map
     131           0 :             OJoinTableView::OTableWindowMap& rMap = m_pTable->getTableView()->GetTabWinMap();
     132           0 :             OJoinTableView::OTableWindowMap::iterator aIter = rMap.begin();
     133           0 :             OJoinTableView::OTableWindowMap::iterator aEnd = rMap.end();
     134           0 :             for (nIndex = 0; aIter != aEnd && aIter->second != m_pTable; ++nIndex,++aIter)
     135             :                 ;
     136           0 :             nIndex = aIter != aEnd ? nIndex : -1;
     137             :         }
     138           0 :         return nIndex;
     139             :     }
     140           0 :     sal_Int16 SAL_CALL OTableWindowAccess::getAccessibleRole(  ) throw (RuntimeException, std::exception)
     141             :     {
     142           0 :         return AccessibleRole::PANEL; // ? or may be an AccessibleRole::WINDOW
     143             :     }
     144           0 :     Reference< XAccessibleRelationSet > SAL_CALL OTableWindowAccess::getAccessibleRelationSet(  ) throw (RuntimeException, std::exception)
     145             :     {
     146           0 :         ::osl::MutexGuard aGuard( m_aMutex  );
     147           0 :         return this;
     148             :     }
     149             :     // XAccessibleComponent
     150           0 :     Reference< XAccessible > SAL_CALL OTableWindowAccess::getAccessibleAtPoint( const awt::Point& _aPoint ) throw (RuntimeException, std::exception)
     151             :     {
     152           0 :         ::osl::MutexGuard aGuard( m_aMutex  );
     153           0 :         Reference< XAccessible > aRet;
     154           0 :         if( m_pTable )
     155             :         {
     156           0 :             Point aPoint(_aPoint.X,_aPoint.Y);
     157           0 :             Rectangle aRect(m_pTable->GetDesktopRectPixel());
     158           0 :             if( aRect.IsInside(aPoint) )
     159           0 :                 aRet = this;
     160           0 :             else if( m_pTable->GetListBox()->GetDesktopRectPixel().IsInside(aPoint))
     161           0 :                 aRet = m_pTable->GetListBox()->GetAccessible();
     162             :         }
     163           0 :         return aRet;
     164             :     }
     165           0 :     Reference< XAccessible > OTableWindowAccess::getParentChild(sal_Int32 _nIndex)
     166             :     {
     167           0 :         Reference< XAccessible > xReturn;
     168           0 :         Reference< XAccessible > xParent = getAccessibleParent();
     169           0 :         if ( xParent.is() )
     170             :         {
     171           0 :             Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext();
     172           0 :             if ( xParentContext.is() )
     173             :             {
     174           0 :                 xReturn = xParentContext->getAccessibleChild(_nIndex);
     175           0 :             }
     176             :         }
     177           0 :         return xReturn;
     178             :     }
     179             : 
     180           0 :     sal_Int32 SAL_CALL OTableWindowAccess::getRelationCount(  ) throw (RuntimeException, std::exception)
     181             :     {
     182           0 :         ::osl::MutexGuard aGuard( m_aMutex  );
     183           0 :         return m_pTable ? m_pTable->getTableView()->getConnectionCount(m_pTable) : sal_Int32(0);
     184             :     }
     185           0 :     AccessibleRelation SAL_CALL OTableWindowAccess::getRelation( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     186             :     {
     187           0 :         ::osl::MutexGuard aGuard( m_aMutex  );
     188           0 :         if( nIndex < 0 || nIndex >= getRelationCount() )
     189           0 :             throw IndexOutOfBoundsException();
     190             : 
     191           0 :         AccessibleRelation aRet;
     192           0 :         if( m_pTable )
     193             :         {
     194           0 :             OJoinTableView* pView = m_pTable->getTableView();
     195           0 :             auto aIter = pView->getTableConnections(m_pTable) + nIndex;
     196           0 :             aRet.TargetSet.realloc(1);
     197           0 :             aRet.TargetSet[0] = getParentChild(aIter - pView->getTableConnections().begin());
     198           0 :             aRet.RelationType = AccessibleRelationType::CONTROLLER_FOR;
     199             :         }
     200           0 :         return aRet;
     201             :     }
     202           0 :     sal_Bool SAL_CALL OTableWindowAccess::containsRelation( sal_Int16 aRelationType ) throw (RuntimeException, std::exception)
     203             :     {
     204           0 :         ::osl::MutexGuard aGuard( m_aMutex  );
     205             :         return      AccessibleRelationType::CONTROLLER_FOR == aRelationType
     206           0 :                 &&  m_pTable && m_pTable->getTableView()->ExistsAConn(m_pTable);
     207             :     }
     208           0 :     AccessibleRelation SAL_CALL OTableWindowAccess::getRelationByType( sal_Int16 aRelationType ) throw (RuntimeException, std::exception)
     209             :     {
     210           0 :         ::osl::MutexGuard aGuard( m_aMutex  );
     211           0 :         if( AccessibleRelationType::CONTROLLER_FOR == aRelationType && m_pTable)
     212             :         {
     213           0 :             OJoinTableView* pView = m_pTable->getTableView();
     214           0 :             const auto& rConnectionList = pView->getTableConnections();
     215             : 
     216           0 :             auto aIter = pView->getTableConnections(m_pTable);
     217           0 :             auto aEnd = rConnectionList.end();
     218           0 :             ::std::vector< Reference<XInterface> > aRelations;
     219           0 :             aRelations.reserve(5); // just guessing
     220           0 :             for (; aIter != aEnd ; ++aIter )
     221             :             {
     222             :                 uno::Reference<uno::XInterface> xInterface(
     223           0 :                     getParentChild(aIter - rConnectionList.begin()));
     224           0 :                 aRelations.push_back(xInterface);
     225           0 :             }
     226             : 
     227           0 :             Sequence< Reference<XInterface> > aSeq(aRelations.data(), aRelations.size());
     228           0 :             return AccessibleRelation(AccessibleRelationType::CONTROLLER_FOR,aSeq);
     229             :         }
     230           0 :         return AccessibleRelation();
     231             :     }
     232           0 :     OUString SAL_CALL OTableWindowAccess::getTitledBorderText(  ) throw (RuntimeException, std::exception)
     233             :     {
     234           0 :         return getAccessibleName(  );
     235             :     }
     236           0 :     OUString SAL_CALL OTableWindowAccess::getAccessibleName(  ) throw (RuntimeException, std::exception)
     237             :     {
     238           0 :         ::osl::MutexGuard aGuard( m_aMutex  );
     239           0 :         OUString sAccessibleName;
     240           0 :         if ( m_pTable )
     241           0 :             sAccessibleName = m_pTable->getTitle();
     242           0 :         return sAccessibleName;
     243             :     }
     244           0 :     Reference< XAccessibleContext > SAL_CALL OTableWindowAccess::getAccessibleContext(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     245             :     {
     246           0 :         return this;
     247             :     }
     248             : 
     249          36 : }
     250             : 
     251             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11