LCOV - code coverage report
Current view: top level - dbaccess/source/ui/querydesign - TableWindowAccess.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 134 0.0 %
Date: 2014-04-14 Functions: 0 24 0.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(void) 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(void) 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 :             if(m_pTable->GetTitleCtrl())
      99           0 :                 ++nCount;
     100           0 :             if(m_pTable->GetListBox())
     101           0 :                 ++nCount;
     102             :         }
     103           0 :         return nCount;
     104             :     }
     105           0 :     Reference< XAccessible > SAL_CALL OTableWindowAccess::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException,RuntimeException, std::exception)
     106             :     {
     107           0 :         ::osl::MutexGuard aGuard( m_aMutex );
     108           0 :         Reference< XAccessible > aRet;
     109           0 :         if(m_pTable)
     110             :         {
     111           0 :             switch(i)
     112             :             {
     113             :                 case 0:
     114           0 :                     if(m_pTable->GetTitleCtrl())
     115             :                     {
     116           0 :                         aRet = m_pTable->GetTitleCtrl()->GetAccessible();
     117           0 :                         break;
     118             :                     } // fall through if title control does not exist
     119             :                 case 1:
     120           0 :                     if(m_pTable->GetListBox())
     121           0 :                         aRet = m_pTable->GetListBox()->GetAccessible();
     122           0 :                     break;
     123             :                 default:
     124           0 :                     throw IndexOutOfBoundsException();
     125             :             }
     126             :         }
     127           0 :         return aRet;
     128             :     }
     129           0 :     sal_Int32 SAL_CALL OTableWindowAccess::getAccessibleIndexInParent(  ) throw (RuntimeException, std::exception)
     130             :     {
     131           0 :         ::osl::MutexGuard aGuard( m_aMutex  );
     132           0 :         sal_Int32 nIndex = -1;
     133           0 :         if( m_pTable )
     134             :         {
     135             :             // search the postion of our table window in the table window map
     136           0 :             OJoinTableView::OTableWindowMap* pMap = m_pTable->getTableView()->GetTabWinMap();
     137           0 :             OJoinTableView::OTableWindowMap::iterator aIter = pMap->begin();
     138           0 :             OJoinTableView::OTableWindowMap::iterator aEnd = pMap->end();
     139           0 :             for (nIndex = 0; aIter != aEnd && aIter->second != m_pTable; ++nIndex,++aIter)
     140             :                 ;
     141           0 :             nIndex = aIter != aEnd ? nIndex : -1;
     142             :         }
     143           0 :         return nIndex;
     144             :     }
     145           0 :     sal_Int16 SAL_CALL OTableWindowAccess::getAccessibleRole(  ) throw (RuntimeException, std::exception)
     146             :     {
     147           0 :         return AccessibleRole::PANEL; // ? or may be an AccessibleRole::WINDOW
     148             :     }
     149           0 :     Reference< XAccessibleRelationSet > SAL_CALL OTableWindowAccess::getAccessibleRelationSet(  ) throw (RuntimeException, std::exception)
     150             :     {
     151           0 :         ::osl::MutexGuard aGuard( m_aMutex  );
     152           0 :         return this;
     153             :     }
     154             :     // XAccessibleComponent
     155           0 :     Reference< XAccessible > SAL_CALL OTableWindowAccess::getAccessibleAtPoint( const awt::Point& _aPoint ) throw (RuntimeException, std::exception)
     156             :     {
     157           0 :         ::osl::MutexGuard aGuard( m_aMutex  );
     158           0 :         Reference< XAccessible > aRet;
     159           0 :         if( m_pTable )
     160             :         {
     161           0 :             Point aPoint(_aPoint.X,_aPoint.Y);
     162           0 :             Rectangle aRect(m_pTable->GetDesktopRectPixel());
     163           0 :             if( aRect.IsInside(aPoint) )
     164           0 :                 aRet = this;
     165           0 :             else if( m_pTable->GetListBox()->GetDesktopRectPixel().IsInside(aPoint))
     166           0 :                 aRet = m_pTable->GetListBox()->GetAccessible();
     167             :         }
     168           0 :         return aRet;
     169             :     }
     170           0 :     Reference< XAccessible > OTableWindowAccess::getParentChild(sal_Int32 _nIndex)
     171             :     {
     172           0 :         Reference< XAccessible > xReturn;
     173           0 :         Reference< XAccessible > xParent = getAccessibleParent();
     174           0 :         if ( xParent.is() )
     175             :         {
     176           0 :             Reference< XAccessibleContext > xParentContext = xParent->getAccessibleContext();
     177           0 :             if ( xParentContext.is() )
     178             :             {
     179           0 :                 xReturn = xParentContext->getAccessibleChild(_nIndex);
     180           0 :             }
     181             :         }
     182           0 :         return xReturn;
     183             :     }
     184             : 
     185           0 :     sal_Int32 SAL_CALL OTableWindowAccess::getRelationCount(  ) throw (RuntimeException, std::exception)
     186             :     {
     187           0 :         ::osl::MutexGuard aGuard( m_aMutex  );
     188           0 :         return m_pTable ? m_pTable->getTableView()->getConnectionCount(m_pTable) : sal_Int32(0);
     189             :     }
     190           0 :     AccessibleRelation SAL_CALL OTableWindowAccess::getRelation( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     191             :     {
     192           0 :         ::osl::MutexGuard aGuard( m_aMutex  );
     193           0 :         if( nIndex < 0 || nIndex >= getRelationCount() )
     194           0 :             throw IndexOutOfBoundsException();
     195             : 
     196           0 :         AccessibleRelation aRet;
     197           0 :         if( m_pTable )
     198             :         {
     199           0 :             OJoinTableView* pView = m_pTable->getTableView();
     200           0 :             ::std::vector<OTableConnection*>::const_iterator aIter = pView->getTableConnections(m_pTable) + nIndex;
     201           0 :             aRet.TargetSet.realloc(1);
     202           0 :             aRet.TargetSet[0] = getParentChild(aIter - pView->getTableConnections()->begin());
     203           0 :             aRet.RelationType = AccessibleRelationType::CONTROLLER_FOR;
     204             :         }
     205           0 :         return aRet;
     206             :     }
     207           0 :     sal_Bool SAL_CALL OTableWindowAccess::containsRelation( sal_Int16 aRelationType ) throw (RuntimeException, std::exception)
     208             :     {
     209           0 :         ::osl::MutexGuard aGuard( m_aMutex  );
     210             :         return      AccessibleRelationType::CONTROLLER_FOR == aRelationType
     211           0 :                 &&  m_pTable && m_pTable->getTableView()->ExistsAConn(m_pTable);
     212             :     }
     213           0 :     AccessibleRelation SAL_CALL OTableWindowAccess::getRelationByType( sal_Int16 aRelationType ) throw (RuntimeException, std::exception)
     214             :     {
     215           0 :         ::osl::MutexGuard aGuard( m_aMutex  );
     216           0 :         if( AccessibleRelationType::CONTROLLER_FOR == aRelationType && m_pTable)
     217             :         {
     218           0 :             OJoinTableView* pView = m_pTable->getTableView();
     219           0 :             const ::std::vector<OTableConnection*>* pConnectionList = pView->getTableConnections();
     220             : 
     221           0 :             ::std::vector<OTableConnection*>::const_iterator aIter = pView->getTableConnections(m_pTable);
     222           0 :             ::std::vector<OTableConnection*>::const_iterator aEnd = pConnectionList->end();
     223           0 :             ::std::vector< Reference<XInterface> > aRelations;
     224           0 :             aRelations.reserve(5); // just guessing
     225           0 :             for (; aIter != aEnd ; ++aIter )
     226             :             {
     227             :                 uno::Reference<uno::XInterface> xInterface(
     228           0 :                     getParentChild(aIter - pConnectionList->begin()));
     229           0 :                 aRelations.push_back(xInterface);
     230           0 :             }
     231             : 
     232           0 :             Reference<XInterface> *pRelations = aRelations.empty() ? 0 : &aRelations[0];
     233           0 :             Sequence< Reference<XInterface> > aSeq(pRelations, aRelations.size());
     234           0 :             return AccessibleRelation(AccessibleRelationType::CONTROLLER_FOR,aSeq);
     235             :         }
     236           0 :         return AccessibleRelation();
     237             :     }
     238           0 :     sal_Bool OTableWindowAccess::isEditable() const
     239             :     {
     240           0 :         return m_pTable && !m_pTable->getTableView()->getDesignView()->getController().isReadOnly();
     241             :     }
     242           0 :     OUString SAL_CALL OTableWindowAccess::getTitledBorderText(  ) throw (RuntimeException, std::exception)
     243             :     {
     244           0 :         return getAccessibleName(  );
     245             :     }
     246           0 :     OUString SAL_CALL OTableWindowAccess::getAccessibleName(  ) throw (RuntimeException, std::exception)
     247             :     {
     248           0 :         ::osl::MutexGuard aGuard( m_aMutex  );
     249           0 :         OUString sAccessibleName;
     250           0 :         if ( m_pTable )
     251           0 :             sAccessibleName = m_pTable->getTitle();
     252           0 :         return sAccessibleName;
     253             :     }
     254           0 :     Reference< XAccessibleContext > SAL_CALL OTableWindowAccess::getAccessibleContext(  ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     255             :     {
     256           0 :         return this;
     257             :     }
     258             : 
     259             : }
     260             : 
     261             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10