LCOV - code coverage report
Current view: top level - basctl/source/accessibility - accessibledialogwindow.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 457 0.0 %
Date: 2014-04-11 Functions: 0 58 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             : 
      21             : #include <accessibledialogwindow.hxx>
      22             : #include <accessibledialogcontrolshape.hxx>
      23             : #include <baside3.hxx>
      24             : #include <dlged.hxx>
      25             : #include <dlgedmod.hxx>
      26             : #include <dlgedpage.hxx>
      27             : #include <dlgedview.hxx>
      28             : #include <dlgedobj.hxx>
      29             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      30             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      31             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      32             : #include <cppuhelper/supportsservice.hxx>
      33             : #include <unotools/accessiblestatesethelper.hxx>
      34             : #include <unotools/accessiblerelationsethelper.hxx>
      35             : #include <toolkit/awt/vclxfont.hxx>
      36             : #include <toolkit/helper/externallock.hxx>
      37             : #include <toolkit/helper/convert.hxx>
      38             : #include <vcl/svapp.hxx>
      39             : #include <vcl/settings.hxx>
      40             : 
      41             : namespace basctl
      42             : {
      43             : 
      44             : using namespace ::com::sun::star;
      45             : using namespace ::com::sun::star::uno;
      46             : using namespace ::com::sun::star::lang;
      47             : using namespace ::com::sun::star::accessibility;
      48             : using namespace ::comphelper;
      49             : 
      50           0 : AccessibleDialogWindow::ChildDescriptor::ChildDescriptor( DlgEdObj* _pDlgEdObj )
      51             :     :pDlgEdObj( _pDlgEdObj )
      52           0 :     ,rxAccessible( 0 )
      53             : {
      54           0 : }
      55             : 
      56             : 
      57             : 
      58           0 : AccessibleDialogWindow::ChildDescriptor::~ChildDescriptor()
      59             : {
      60           0 : }
      61             : 
      62             : 
      63             : 
      64           0 : AccessibleDialogWindow::ChildDescriptor::ChildDescriptor( const ChildDescriptor& rDesc )
      65             :     :pDlgEdObj( rDesc.pDlgEdObj )
      66           0 :     ,rxAccessible( rDesc.rxAccessible )
      67             : {
      68           0 : }
      69             : 
      70             : 
      71             : 
      72           0 : AccessibleDialogWindow::ChildDescriptor& AccessibleDialogWindow::ChildDescriptor::operator=( const ChildDescriptor& rDesc )
      73             : {
      74           0 :     pDlgEdObj = rDesc.pDlgEdObj;
      75           0 :     rxAccessible = rDesc.rxAccessible;
      76             : 
      77           0 :     return *this;
      78             : }
      79             : 
      80             : 
      81             : 
      82           0 : bool AccessibleDialogWindow::ChildDescriptor::operator==( const ChildDescriptor& rDesc )
      83             : {
      84           0 :     bool bRet = false;
      85           0 :     if ( pDlgEdObj == rDesc.pDlgEdObj )
      86           0 :         bRet = true;
      87             : 
      88           0 :     return bRet;
      89             : }
      90             : 
      91             : 
      92             : 
      93           0 : bool AccessibleDialogWindow::ChildDescriptor::operator<( const ChildDescriptor& rDesc ) const
      94             : {
      95           0 :     bool bRet = false;
      96           0 :     if ( pDlgEdObj && rDesc.pDlgEdObj && pDlgEdObj->GetOrdNum() < rDesc.pDlgEdObj->GetOrdNum() )
      97           0 :         bRet = true;
      98             : 
      99           0 :     return bRet;
     100             : }
     101             : 
     102             : 
     103             : // class AccessibleDialogWindow
     104             : 
     105             : 
     106           0 : AccessibleDialogWindow::AccessibleDialogWindow (basctl::DialogWindow* pDialogWindow)
     107             :     : AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() )
     108             :     , m_pDialogWindow(pDialogWindow)
     109             :     , m_pDlgEditor(NULL)
     110           0 :     , m_pDlgEdModel(NULL)
     111             : {
     112           0 :     m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
     113             : 
     114           0 :     if ( m_pDialogWindow )
     115             :     {
     116           0 :         SdrPage& rPage = m_pDialogWindow->GetPage();
     117           0 :         sal_uLong nCount = rPage.GetObjCount();
     118             : 
     119           0 :         for ( sal_uLong i = 0; i < nCount; ++i )
     120             :         {
     121           0 :             if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i)))
     122             :             {
     123           0 :                 ChildDescriptor aDesc( pDlgEdObj );
     124           0 :                 if ( IsChildVisible( aDesc ) )
     125           0 :                     m_aAccessibleChildren.push_back( aDesc );
     126             :             }
     127             :         }
     128             : 
     129           0 :         m_pDialogWindow->AddEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
     130             : 
     131           0 :         StartListening(m_pDialogWindow->GetEditor());
     132             : 
     133           0 :         m_pDlgEdModel = &m_pDialogWindow->GetModel();
     134           0 :         StartListening(*m_pDlgEdModel);
     135             :     }
     136           0 : }
     137             : 
     138             : 
     139             : 
     140           0 : AccessibleDialogWindow::~AccessibleDialogWindow()
     141             : {
     142           0 :     if ( m_pDialogWindow )
     143           0 :         m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
     144             : 
     145           0 :     if ( m_pDlgEditor )
     146           0 :         EndListening( *m_pDlgEditor );
     147             : 
     148           0 :     if ( m_pDlgEdModel )
     149           0 :         EndListening( *m_pDlgEdModel );
     150             : 
     151           0 :     delete m_pExternalLock;
     152           0 :     m_pExternalLock = NULL;
     153           0 : }
     154             : 
     155             : 
     156             : 
     157           0 : void AccessibleDialogWindow::UpdateFocused()
     158             : {
     159           0 :     for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
     160             :     {
     161           0 :         Reference< XAccessible > xChild( m_aAccessibleChildren[i].rxAccessible );
     162           0 :         if ( xChild.is() )
     163             :         {
     164           0 :             AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
     165           0 :             if ( pShape )
     166           0 :                 pShape->SetFocused( pShape->IsFocused() );
     167             :         }
     168           0 :     }
     169           0 : }
     170             : 
     171             : 
     172             : 
     173           0 : void AccessibleDialogWindow::UpdateSelected()
     174             : {
     175           0 :     NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
     176             : 
     177           0 :     for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
     178             :     {
     179           0 :         Reference< XAccessible > xChild( m_aAccessibleChildren[i].rxAccessible );
     180           0 :         if ( xChild.is() )
     181             :         {
     182           0 :             AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
     183           0 :             if ( pShape )
     184           0 :                 pShape->SetSelected( pShape->IsSelected() );
     185             :         }
     186           0 :     }
     187           0 : }
     188             : 
     189             : 
     190             : 
     191           0 : void AccessibleDialogWindow::UpdateBounds()
     192             : {
     193           0 :     for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
     194             :     {
     195           0 :         Reference< XAccessible > xChild( m_aAccessibleChildren[i].rxAccessible );
     196           0 :         if ( xChild.is() )
     197             :         {
     198           0 :             AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
     199           0 :             if ( pShape )
     200           0 :                 pShape->SetBounds( pShape->GetBounds() );
     201             :         }
     202           0 :     }
     203           0 : }
     204             : 
     205             : 
     206             : 
     207           0 : bool AccessibleDialogWindow::IsChildVisible( const ChildDescriptor& rDesc )
     208             : {
     209           0 :     bool bVisible = false;
     210             : 
     211           0 :     if ( m_pDialogWindow )
     212             :     {
     213             :         // first check, if the shape is in a visible layer
     214           0 :         SdrLayerAdmin& rLayerAdmin = m_pDialogWindow->GetModel().GetLayerAdmin();
     215           0 :         DlgEdObj* pDlgEdObj = rDesc.pDlgEdObj;
     216           0 :         if ( pDlgEdObj )
     217             :         {
     218           0 :             SdrLayerID nLayerId = pDlgEdObj->GetLayer();
     219           0 :             const SdrLayer* pSdrLayer = rLayerAdmin.GetLayerPerID( nLayerId );
     220           0 :             if ( pSdrLayer )
     221             :             {
     222           0 :                 OUString aLayerName = pSdrLayer->GetName();
     223           0 :                 SdrView& rView = m_pDialogWindow->GetView();
     224           0 :                 if (rView.IsLayerVisible(aLayerName))
     225             :                 {
     226             :                     // get the bounding box of the shape in logic units
     227           0 :                     Rectangle aRect = pDlgEdObj->GetSnapRect();
     228             : 
     229             :                     // transform coordinates relative to the parent
     230           0 :                     MapMode aMap = m_pDialogWindow->GetMapMode();
     231           0 :                     Point aOrg = aMap.GetOrigin();
     232           0 :                     aRect.Move( aOrg.X(), aOrg.Y() );
     233             : 
     234             :                     // convert logic units to pixel
     235           0 :                     aRect = m_pDialogWindow->LogicToPixel( aRect, MapMode(MAP_100TH_MM) );
     236             : 
     237             :                     // check, if the shape's bounding box intersects with the bounding box of its parent
     238           0 :                     Rectangle aParentRect( Point( 0, 0 ), m_pDialogWindow->GetSizePixel() );
     239           0 :                     if ( aParentRect.IsOver( aRect ) )
     240           0 :                         bVisible = true;
     241           0 :                 }
     242             :             }
     243             :         }
     244             :     }
     245             : 
     246           0 :     return bVisible;
     247             : }
     248             : 
     249             : 
     250             : 
     251           0 : void AccessibleDialogWindow::InsertChild( const ChildDescriptor& rDesc )
     252             : {
     253             :     // check, if object is already in child list
     254           0 :     AccessibleChildren::iterator aIter = ::std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
     255             : 
     256             :     // if not found, insert in child list
     257           0 :     if ( aIter == m_aAccessibleChildren.end() )
     258             :     {
     259             :         // insert entry in child list
     260           0 :         m_aAccessibleChildren.push_back( rDesc );
     261             : 
     262             :         // get the accessible of the inserted child
     263           0 :         Reference< XAccessible > xChild( getAccessibleChild( m_aAccessibleChildren.size() - 1 ) );
     264             : 
     265             :         // sort child list
     266           0 :         SortChildren();
     267             : 
     268             :         // send accessible child event
     269           0 :         if ( xChild.is() )
     270             :         {
     271           0 :             Any aOldValue, aNewValue;
     272           0 :             aNewValue <<= xChild;
     273           0 :             NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
     274           0 :         }
     275             :     }
     276           0 : }
     277             : 
     278             : 
     279             : 
     280           0 : void AccessibleDialogWindow::RemoveChild( const ChildDescriptor& rDesc )
     281             : {
     282             :     // find object in child list
     283           0 :     AccessibleChildren::iterator aIter = ::std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
     284             : 
     285             :     // if found, remove from child list
     286           0 :     if ( aIter != m_aAccessibleChildren.end() )
     287             :     {
     288             :         // get the accessible of the removed child
     289           0 :         Reference< XAccessible > xChild( aIter->rxAccessible );
     290             : 
     291             :         // remove entry from child list
     292           0 :         m_aAccessibleChildren.erase( aIter );
     293             : 
     294             :         // send accessible child event
     295           0 :         if ( xChild.is() )
     296             :         {
     297           0 :             Any aOldValue, aNewValue;
     298           0 :             aOldValue <<= xChild;
     299           0 :             NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
     300             : 
     301           0 :             Reference< XComponent > xComponent( xChild, UNO_QUERY );
     302           0 :             if ( xComponent.is() )
     303           0 :                 xComponent->dispose();
     304           0 :         }
     305             :     }
     306           0 : }
     307             : 
     308             : 
     309             : 
     310           0 : void AccessibleDialogWindow::UpdateChild( const ChildDescriptor& rDesc )
     311             : {
     312           0 :     if ( IsChildVisible( rDesc ) )
     313             :     {
     314             :         // if the object is not in the child list, insert child
     315           0 :         InsertChild( rDesc );
     316             :     }
     317             :     else
     318             :     {
     319             :         // if the object is in the child list, remove child
     320           0 :         RemoveChild( rDesc );
     321             :     }
     322           0 : }
     323             : 
     324             : 
     325             : 
     326           0 : void AccessibleDialogWindow::UpdateChildren()
     327             : {
     328           0 :     if ( m_pDialogWindow )
     329             :     {
     330           0 :         SdrPage& rPage = m_pDialogWindow->GetPage();
     331           0 :         for ( sal_uLong i = 0, nCount = rPage.GetObjCount(); i < nCount; ++i )
     332           0 :             if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i)))
     333           0 :                 UpdateChild( ChildDescriptor( pDlgEdObj ) );
     334             :     }
     335           0 : }
     336             : 
     337             : 
     338             : 
     339           0 : void AccessibleDialogWindow::SortChildren()
     340             : {
     341             :     // sort child list
     342           0 :     ::std::sort( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end() );
     343           0 : }
     344             : 
     345             : 
     346             : 
     347           0 : IMPL_LINK( AccessibleDialogWindow, WindowEventListener, VclSimpleEvent*, pEvent )
     348             : {
     349           0 :     if (VclWindowEvent* pWinEvent = dynamic_cast<VclWindowEvent*>(pEvent))
     350             :     {
     351             :         DBG_ASSERT(pWinEvent->GetWindow(), "AccessibleDialogWindow::WindowEventListener: no window!");
     352           0 :         if (!pWinEvent->GetWindow()->IsAccessibilityEventsSuppressed() || pEvent->GetId() == VCLEVENT_OBJECT_DYING)
     353           0 :             ProcessWindowEvent(*pWinEvent);
     354             :     }
     355             :     else
     356             :         DBG_ASSERT(false, "AccessibleDialogWindow::WindowEventListener: unknown window event!");
     357           0 :     return 0;
     358             : }
     359             : 
     360             : 
     361             : 
     362           0 : void AccessibleDialogWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
     363             : {
     364           0 :     Any aOldValue, aNewValue;
     365             : 
     366           0 :     switch ( rVclWindowEvent.GetId() )
     367             :     {
     368             :         case VCLEVENT_WINDOW_ENABLED:
     369             :         {
     370           0 :             aNewValue <<= AccessibleStateType::ENABLED;
     371           0 :             NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     372             :         }
     373           0 :         break;
     374             :         case VCLEVENT_WINDOW_DISABLED:
     375             :         {
     376           0 :             aOldValue <<= AccessibleStateType::ENABLED;
     377           0 :             NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     378             :         }
     379           0 :         break;
     380             :         case VCLEVENT_WINDOW_ACTIVATE:
     381             :         {
     382           0 :             aNewValue <<= AccessibleStateType::ACTIVE;
     383           0 :             NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     384             :         }
     385           0 :         break;
     386             :         case VCLEVENT_WINDOW_DEACTIVATE:
     387             :         {
     388           0 :             aOldValue <<= AccessibleStateType::ACTIVE;
     389           0 :             NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     390             :         }
     391           0 :         break;
     392             :         case VCLEVENT_WINDOW_GETFOCUS:
     393             :         {
     394           0 :             aNewValue <<= AccessibleStateType::FOCUSED;
     395           0 :             NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     396             :         }
     397           0 :         break;
     398             :         case VCLEVENT_WINDOW_LOSEFOCUS:
     399             :         {
     400           0 :             aOldValue <<= AccessibleStateType::FOCUSED;
     401           0 :             NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     402             :         }
     403           0 :         break;
     404             :         case VCLEVENT_WINDOW_SHOW:
     405             :         {
     406           0 :             aNewValue <<= AccessibleStateType::SHOWING;
     407           0 :             NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     408             :         }
     409           0 :         break;
     410             :         case VCLEVENT_WINDOW_HIDE:
     411             :         {
     412           0 :             aOldValue <<= AccessibleStateType::SHOWING;
     413           0 :             NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     414             :         }
     415           0 :         break;
     416             :         case VCLEVENT_WINDOW_RESIZE:
     417             :         {
     418           0 :             NotifyAccessibleEvent( AccessibleEventId::BOUNDRECT_CHANGED, aOldValue, aNewValue );
     419           0 :             UpdateChildren();
     420           0 :             UpdateBounds();
     421             :         }
     422           0 :         break;
     423             :         case VCLEVENT_OBJECT_DYING:
     424             :         {
     425           0 :             if ( m_pDialogWindow )
     426             :             {
     427           0 :                 m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
     428           0 :                 m_pDialogWindow = NULL;
     429             : 
     430           0 :                 if ( m_pDlgEditor )
     431           0 :                     EndListening( *m_pDlgEditor );
     432           0 :                 m_pDlgEditor = NULL;
     433             : 
     434           0 :                 if ( m_pDlgEdModel )
     435           0 :                     EndListening( *m_pDlgEdModel );
     436           0 :                 m_pDlgEdModel = NULL;
     437             : 
     438             :                 // dispose all children
     439           0 :                 for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
     440             :                 {
     441           0 :                     Reference< XComponent > xComponent( m_aAccessibleChildren[i].rxAccessible, UNO_QUERY );
     442           0 :                     if ( xComponent.is() )
     443           0 :                         xComponent->dispose();
     444           0 :                 }
     445           0 :                 m_aAccessibleChildren.clear();
     446             :             }
     447             :         }
     448           0 :         break;
     449             :         default:
     450             :         {
     451             :         }
     452           0 :         break;
     453           0 :     }
     454           0 : }
     455             : 
     456             : 
     457             : 
     458           0 : void AccessibleDialogWindow::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
     459             : {
     460           0 :     if ( m_pDialogWindow )
     461             :     {
     462           0 :         if ( m_pDialogWindow->IsEnabled() )
     463           0 :             rStateSet.AddState( AccessibleStateType::ENABLED );
     464             : 
     465           0 :         rStateSet.AddState( AccessibleStateType::FOCUSABLE );
     466             : 
     467           0 :         if ( m_pDialogWindow->HasFocus() )
     468           0 :             rStateSet.AddState( AccessibleStateType::FOCUSED );
     469             : 
     470           0 :         rStateSet.AddState( AccessibleStateType::VISIBLE );
     471             : 
     472           0 :         if ( m_pDialogWindow->IsVisible() )
     473           0 :             rStateSet.AddState( AccessibleStateType::SHOWING );
     474             : 
     475           0 :         rStateSet.AddState( AccessibleStateType::OPAQUE );
     476             : 
     477           0 :         rStateSet.AddState( AccessibleStateType::RESIZABLE );
     478             :     }
     479           0 : }
     480             : 
     481             : 
     482             : // OCommonAccessibleComponent
     483             : 
     484             : 
     485           0 : awt::Rectangle AccessibleDialogWindow::implGetBounds() throw (RuntimeException)
     486             : {
     487           0 :     awt::Rectangle aBounds;
     488           0 :     if ( m_pDialogWindow )
     489           0 :         aBounds = AWTRectangle( Rectangle( m_pDialogWindow->GetPosPixel(), m_pDialogWindow->GetSizePixel() ) );
     490             : 
     491           0 :     return aBounds;
     492             : }
     493             : 
     494             : 
     495             : // SfxListener
     496             : 
     497             : 
     498           0 : void AccessibleDialogWindow::Notify( SfxBroadcaster&, const SfxHint& rHint )
     499             : {
     500           0 :     if (SdrHint const* pSdrHint = dynamic_cast<SdrHint const*>(&rHint))
     501             :     {
     502           0 :         switch ( pSdrHint->GetKind() )
     503             :         {
     504             :             case HINT_OBJINSERTED:
     505             :             {
     506           0 :                 if (DlgEdObj const* pDlgEdObj = dynamic_cast<DlgEdObj const*>(pSdrHint->GetObject()))
     507             :                 {
     508           0 :                     ChildDescriptor aDesc(const_cast<DlgEdObj*>(pDlgEdObj));
     509           0 :                     if ( IsChildVisible( aDesc ) )
     510           0 :                         InsertChild( aDesc );
     511             :                 }
     512             :             }
     513           0 :             break;
     514             :             case HINT_OBJREMOVED:
     515             :             {
     516           0 :                 if (DlgEdObj const* pDlgEdObj = dynamic_cast<DlgEdObj const*>(pSdrHint->GetObject()))
     517           0 :                     RemoveChild( ChildDescriptor(const_cast<DlgEdObj*>(pDlgEdObj)) );
     518             :             }
     519           0 :             break;
     520             :             default: ;
     521             :         }
     522             :     }
     523           0 :     else if (DlgEdHint const* pDlgEdHint = dynamic_cast<DlgEdHint const*>(&rHint))
     524             :     {
     525           0 :         switch (pDlgEdHint->GetKind())
     526             :         {
     527             :             case DlgEdHint::WINDOWSCROLLED:
     528             :             {
     529           0 :                 UpdateChildren();
     530           0 :                 UpdateBounds();
     531             :             }
     532           0 :             break;
     533             :             case DlgEdHint::LAYERCHANGED:
     534             :             {
     535           0 :                 if (DlgEdObj* pDlgEdObj = pDlgEdHint->GetObject())
     536           0 :                     UpdateChild( ChildDescriptor( pDlgEdObj ) );
     537             :             }
     538           0 :             break;
     539             :             case DlgEdHint::OBJORDERCHANGED:
     540             :             {
     541           0 :                 SortChildren();
     542             :             }
     543           0 :             break;
     544             :             case DlgEdHint::SELECTIONCHANGED:
     545             :             {
     546           0 :                 UpdateFocused();
     547           0 :                 UpdateSelected();
     548             :             }
     549           0 :             break;
     550             :             default: ;
     551             :         }
     552             :     }
     553           0 : }
     554             : 
     555             : 
     556             : // XInterface
     557             : 
     558             : 
     559           0 : IMPLEMENT_FORWARD_XINTERFACE2( AccessibleDialogWindow, AccessibleExtendedComponentHelper_BASE, AccessibleDialogWindow_BASE )
     560             : 
     561             : 
     562             : // XTypeProvider
     563             : 
     564             : 
     565           0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleDialogWindow, AccessibleExtendedComponentHelper_BASE, AccessibleDialogWindow_BASE )
     566             : 
     567             : 
     568             : // XComponent
     569             : 
     570             : 
     571           0 : void AccessibleDialogWindow::disposing()
     572             : {
     573           0 :     AccessibleExtendedComponentHelper_BASE::disposing();
     574             : 
     575           0 :     if ( m_pDialogWindow )
     576             :     {
     577           0 :         m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
     578           0 :         m_pDialogWindow = NULL;
     579             : 
     580           0 :         if ( m_pDlgEditor )
     581           0 :             EndListening( *m_pDlgEditor );
     582           0 :         m_pDlgEditor = NULL;
     583             : 
     584           0 :         if ( m_pDlgEdModel )
     585           0 :             EndListening( *m_pDlgEdModel );
     586           0 :         m_pDlgEdModel = NULL;
     587             : 
     588             :         // dispose all children
     589           0 :         for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
     590             :         {
     591           0 :             Reference< XComponent > xComponent( m_aAccessibleChildren[i].rxAccessible, UNO_QUERY );
     592           0 :             if ( xComponent.is() )
     593           0 :                 xComponent->dispose();
     594           0 :         }
     595           0 :         m_aAccessibleChildren.clear();
     596             :     }
     597           0 : }
     598             : 
     599             : // XServiceInfo
     600           0 : OUString AccessibleDialogWindow::getImplementationName() throw (RuntimeException, std::exception)
     601             : {
     602           0 :     return OUString( "com.sun.star.comp.basctl.AccessibleWindow" );
     603             : }
     604             : 
     605           0 : sal_Bool AccessibleDialogWindow::supportsService( const OUString& rServiceName ) throw (RuntimeException, std::exception)
     606             : {
     607           0 :     return cppu::supportsService(this, rServiceName);
     608             : }
     609             : 
     610           0 : Sequence< OUString > AccessibleDialogWindow::getSupportedServiceNames() throw (RuntimeException, std::exception)
     611             : {
     612           0 :     Sequence< OUString > aNames(1);
     613           0 :     aNames[0] = "com.sun.star.awt.AccessibleWindow" ;
     614           0 :     return aNames;
     615             : }
     616             : 
     617             : // XAccessible
     618           0 : Reference< XAccessibleContext > AccessibleDialogWindow::getAccessibleContext(  ) throw (RuntimeException, std::exception)
     619             : {
     620           0 :     OExternalLockGuard aGuard( this );
     621             : 
     622           0 :     return this;
     623             : }
     624             : 
     625             : // XAccessibleContext
     626           0 : sal_Int32 AccessibleDialogWindow::getAccessibleChildCount() throw (RuntimeException, std::exception)
     627             : {
     628           0 :     OExternalLockGuard aGuard( this );
     629             : 
     630           0 :     return m_aAccessibleChildren.size();
     631             : }
     632             : 
     633             : 
     634             : 
     635           0 : Reference< XAccessible > AccessibleDialogWindow::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     636             : {
     637           0 :     OExternalLockGuard aGuard( this );
     638             : 
     639           0 :     if ( i < 0 || i >= getAccessibleChildCount() )
     640           0 :         throw IndexOutOfBoundsException();
     641             : 
     642           0 :     Reference< XAccessible > xChild = m_aAccessibleChildren[i].rxAccessible;
     643           0 :     if ( !xChild.is() )
     644             :     {
     645           0 :         if ( m_pDialogWindow )
     646             :         {
     647           0 :             DlgEdObj* pDlgEdObj = m_aAccessibleChildren[i].pDlgEdObj;
     648           0 :             if ( pDlgEdObj )
     649             :             {
     650           0 :                 xChild = new AccessibleDialogControlShape( m_pDialogWindow, pDlgEdObj );
     651             : 
     652             :                 // insert into child list
     653           0 :                 m_aAccessibleChildren[i].rxAccessible = xChild;
     654             :             }
     655             :         }
     656             :     }
     657             : 
     658           0 :     return xChild;
     659             : }
     660             : 
     661             : 
     662             : 
     663           0 : Reference< XAccessible > AccessibleDialogWindow::getAccessibleParent(  ) throw (RuntimeException, std::exception)
     664             : {
     665           0 :     OExternalLockGuard aGuard( this );
     666             : 
     667           0 :     Reference< XAccessible > xParent;
     668           0 :     if ( m_pDialogWindow )
     669             :     {
     670           0 :         Window* pParent = m_pDialogWindow->GetAccessibleParentWindow();
     671           0 :         if ( pParent )
     672           0 :             xParent = pParent->GetAccessible();
     673             :     }
     674             : 
     675           0 :     return xParent;
     676             : }
     677             : 
     678             : 
     679             : 
     680           0 : sal_Int32 AccessibleDialogWindow::getAccessibleIndexInParent(  ) throw (RuntimeException, std::exception)
     681             : {
     682           0 :     OExternalLockGuard aGuard( this );
     683             : 
     684           0 :     sal_Int32 nIndexInParent = -1;
     685           0 :     if ( m_pDialogWindow )
     686             :     {
     687           0 :         Window* pParent = m_pDialogWindow->GetAccessibleParentWindow();
     688           0 :         if ( pParent )
     689             :         {
     690           0 :             for ( sal_uInt16 i = 0, nCount = pParent->GetAccessibleChildWindowCount(); i < nCount; ++i )
     691             :             {
     692           0 :                 Window* pChild = pParent->GetAccessibleChildWindow( i );
     693           0 :                 if ( pChild == static_cast< Window* >( m_pDialogWindow ) )
     694             :                 {
     695           0 :                     nIndexInParent = i;
     696           0 :                     break;
     697             :                 }
     698             :             }
     699             :         }
     700             :     }
     701             : 
     702           0 :     return nIndexInParent;
     703             : }
     704             : 
     705             : 
     706             : 
     707           0 : sal_Int16 AccessibleDialogWindow::getAccessibleRole(  ) throw (RuntimeException, std::exception)
     708             : {
     709           0 :     OExternalLockGuard aGuard( this );
     710             : 
     711           0 :     return AccessibleRole::PANEL;
     712             : }
     713             : 
     714             : 
     715             : 
     716           0 : OUString AccessibleDialogWindow::getAccessibleDescription(  ) throw (RuntimeException, std::exception)
     717             : {
     718           0 :     OExternalLockGuard aGuard( this );
     719             : 
     720           0 :     OUString sDescription;
     721           0 :     if ( m_pDialogWindow )
     722           0 :         sDescription = m_pDialogWindow->GetAccessibleDescription();
     723             : 
     724           0 :     return sDescription;
     725             : }
     726             : 
     727             : 
     728             : 
     729           0 : OUString AccessibleDialogWindow::getAccessibleName(  ) throw (RuntimeException, std::exception)
     730             : {
     731           0 :     OExternalLockGuard aGuard( this );
     732             : 
     733           0 :     OUString sName;
     734           0 :     if ( m_pDialogWindow )
     735           0 :         sName = m_pDialogWindow->GetAccessibleName();
     736             : 
     737           0 :     return sName;
     738             : }
     739             : 
     740             : 
     741             : 
     742           0 : Reference< XAccessibleRelationSet > AccessibleDialogWindow::getAccessibleRelationSet(  ) throw (RuntimeException, std::exception)
     743             : {
     744           0 :     OExternalLockGuard aGuard( this );
     745             : 
     746           0 :     utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
     747           0 :     Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
     748           0 :     return xSet;
     749             : }
     750             : 
     751             : 
     752             : 
     753           0 : Reference< XAccessibleStateSet > AccessibleDialogWindow::getAccessibleStateSet(  ) throw (RuntimeException, std::exception)
     754             : {
     755           0 :     OExternalLockGuard aGuard( this );
     756             : 
     757           0 :     utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
     758           0 :     Reference< XAccessibleStateSet > xSet = pStateSetHelper;
     759             : 
     760           0 :     if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
     761             :     {
     762           0 :         FillAccessibleStateSet( *pStateSetHelper );
     763             :     }
     764             :     else
     765             :     {
     766           0 :         pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
     767             :     }
     768             : 
     769           0 :     return xSet;
     770             : }
     771             : 
     772             : 
     773             : 
     774           0 : Locale AccessibleDialogWindow::getLocale(  ) throw (IllegalAccessibleComponentStateException, RuntimeException, std::exception)
     775             : {
     776           0 :     OExternalLockGuard aGuard( this );
     777             : 
     778           0 :     return Application::GetSettings().GetLanguageTag().getLocale();
     779             : }
     780             : 
     781             : 
     782             : // XAccessibleComponent
     783             : 
     784             : 
     785           0 : Reference< XAccessible > AccessibleDialogWindow::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException, std::exception)
     786             : {
     787           0 :     OExternalLockGuard aGuard( this );
     788             : 
     789           0 :     Reference< XAccessible > xChild;
     790           0 :     for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
     791             :     {
     792           0 :         Reference< XAccessible > xAcc = getAccessibleChild( i );
     793           0 :         if ( xAcc.is() )
     794             :         {
     795           0 :             Reference< XAccessibleComponent > xComp( xAcc->getAccessibleContext(), UNO_QUERY );
     796           0 :             if ( xComp.is() )
     797             :             {
     798           0 :                 Rectangle aRect = VCLRectangle( xComp->getBounds() );
     799           0 :                 Point aPos = VCLPoint( rPoint );
     800           0 :                 if ( aRect.IsInside( aPos ) )
     801             :                 {
     802           0 :                     xChild = xAcc;
     803           0 :                     break;
     804             :                 }
     805           0 :             }
     806             :         }
     807           0 :     }
     808             : 
     809           0 :     return xChild;
     810             : }
     811             : 
     812             : 
     813             : 
     814           0 : void AccessibleDialogWindow::grabFocus(  ) throw (RuntimeException, std::exception)
     815             : {
     816           0 :     OExternalLockGuard aGuard( this );
     817             : 
     818           0 :     if ( m_pDialogWindow )
     819           0 :         m_pDialogWindow->GrabFocus();
     820           0 : }
     821             : 
     822             : 
     823             : 
     824           0 : sal_Int32 AccessibleDialogWindow::getForeground(  ) throw (RuntimeException, std::exception)
     825             : {
     826           0 :     OExternalLockGuard aGuard( this );
     827             : 
     828           0 :     sal_Int32 nColor = 0;
     829           0 :     if ( m_pDialogWindow )
     830             :     {
     831           0 :         if ( m_pDialogWindow->IsControlForeground() )
     832           0 :             nColor = m_pDialogWindow->GetControlForeground().GetColor();
     833             :         else
     834             :         {
     835           0 :             Font aFont;
     836           0 :             if ( m_pDialogWindow->IsControlFont() )
     837           0 :                 aFont = m_pDialogWindow->GetControlFont();
     838             :             else
     839           0 :                 aFont = m_pDialogWindow->GetFont();
     840           0 :             nColor = aFont.GetColor().GetColor();
     841             :         }
     842             :     }
     843             : 
     844           0 :     return nColor;
     845             : }
     846             : 
     847             : 
     848             : 
     849           0 : sal_Int32 AccessibleDialogWindow::getBackground(  ) throw (RuntimeException, std::exception)
     850             : {
     851           0 :     OExternalLockGuard aGuard( this );
     852             : 
     853           0 :     sal_Int32 nColor = 0;
     854           0 :     if ( m_pDialogWindow )
     855             :     {
     856           0 :         if ( m_pDialogWindow->IsControlBackground() )
     857           0 :             nColor = m_pDialogWindow->GetControlBackground().GetColor();
     858             :         else
     859           0 :             nColor = m_pDialogWindow->GetBackground().GetColor().GetColor();
     860             :     }
     861             : 
     862           0 :     return nColor;
     863             : }
     864             : 
     865             : 
     866             : // XAccessibleExtendedComponent
     867             : 
     868             : 
     869           0 : Reference< awt::XFont > AccessibleDialogWindow::getFont(  ) throw (RuntimeException, std::exception)
     870             : {
     871           0 :     OExternalLockGuard aGuard( this );
     872             : 
     873           0 :     Reference< awt::XFont > xFont;
     874           0 :     if ( m_pDialogWindow )
     875             :     {
     876           0 :         Reference< awt::XDevice > xDev( m_pDialogWindow->GetComponentInterface(), UNO_QUERY );
     877           0 :         if ( xDev.is() )
     878             :         {
     879           0 :             Font aFont;
     880           0 :             if ( m_pDialogWindow->IsControlFont() )
     881           0 :                 aFont = m_pDialogWindow->GetControlFont();
     882             :             else
     883           0 :                 aFont = m_pDialogWindow->GetFont();
     884           0 :             VCLXFont* pVCLXFont = new VCLXFont;
     885           0 :             pVCLXFont->Init( *xDev.get(), aFont );
     886           0 :             xFont = pVCLXFont;
     887           0 :         }
     888             :     }
     889             : 
     890           0 :     return xFont;
     891             : }
     892             : 
     893             : 
     894             : 
     895           0 : OUString AccessibleDialogWindow::getTitledBorderText(  ) throw (RuntimeException, std::exception)
     896             : {
     897           0 :     OExternalLockGuard aGuard( this );
     898             : 
     899           0 :     return OUString();
     900             : }
     901             : 
     902             : 
     903             : 
     904           0 : OUString AccessibleDialogWindow::getToolTipText(  ) throw (RuntimeException, std::exception)
     905             : {
     906           0 :     OExternalLockGuard aGuard( this );
     907             : 
     908           0 :     OUString sText;
     909           0 :     if ( m_pDialogWindow )
     910           0 :         sText = m_pDialogWindow->GetQuickHelpText();
     911             : 
     912           0 :     return sText;
     913             : }
     914             : 
     915             : 
     916             : // XAccessibleSelection
     917             : 
     918             : 
     919           0 : void AccessibleDialogWindow::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     920             : {
     921           0 :     OExternalLockGuard aGuard( this );
     922             : 
     923           0 :     if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
     924           0 :         throw IndexOutOfBoundsException();
     925             : 
     926           0 :     if ( m_pDialogWindow )
     927             :     {
     928           0 :         if (DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj)
     929             :         {
     930           0 :             SdrView& rView = m_pDialogWindow->GetView();
     931           0 :             if (SdrPageView* pPgView = rView.GetSdrPageView())
     932           0 :                 rView.MarkObj(pDlgEdObj, pPgView);
     933             :         }
     934           0 :     }
     935           0 : }
     936             : 
     937             : 
     938             : 
     939           0 : sal_Bool AccessibleDialogWindow::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     940             : {
     941           0 :     OExternalLockGuard aGuard( this );
     942             : 
     943           0 :     if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
     944           0 :         throw IndexOutOfBoundsException();
     945             : 
     946           0 :     if (m_pDialogWindow)
     947           0 :         if (DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj)
     948           0 :             return m_pDialogWindow->GetView().IsObjMarked(pDlgEdObj);
     949           0 :     return false;
     950             : }
     951             : 
     952             : 
     953             : 
     954           0 : void AccessibleDialogWindow::clearAccessibleSelection()
     955             :     throw (RuntimeException, std::exception)
     956             : {
     957           0 :     OExternalLockGuard aGuard( this );
     958             : 
     959           0 :     if ( m_pDialogWindow )
     960           0 :         m_pDialogWindow->GetView().UnmarkAll();
     961           0 : }
     962             : 
     963             : 
     964             : 
     965           0 : void AccessibleDialogWindow::selectAllAccessibleChildren(  ) throw (RuntimeException, std::exception)
     966             : {
     967           0 :     OExternalLockGuard aGuard( this );
     968             : 
     969           0 :     if ( m_pDialogWindow )
     970           0 :         m_pDialogWindow->GetView().MarkAll();
     971           0 : }
     972             : 
     973             : 
     974             : 
     975           0 : sal_Int32 AccessibleDialogWindow::getSelectedAccessibleChildCount(  ) throw (RuntimeException, std::exception)
     976             : {
     977           0 :     OExternalLockGuard aGuard( this );
     978             : 
     979           0 :     sal_Int32 nRet = 0;
     980             : 
     981           0 :     for ( sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
     982             :     {
     983           0 :         if ( isAccessibleChildSelected( i ) )
     984           0 :             ++nRet;
     985             :     }
     986             : 
     987           0 :     return nRet;
     988             : }
     989             : 
     990             : 
     991             : 
     992           0 : Reference< XAccessible > AccessibleDialogWindow::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     993             : {
     994           0 :     OExternalLockGuard aGuard( this );
     995             : 
     996           0 :     if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
     997           0 :         throw IndexOutOfBoundsException();
     998             : 
     999           0 :     Reference< XAccessible > xChild;
    1000             : 
    1001           0 :     for ( sal_Int32 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
    1002             :     {
    1003           0 :         if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
    1004             :         {
    1005           0 :             xChild = getAccessibleChild( i );
    1006           0 :             break;
    1007             :         }
    1008             :     }
    1009             : 
    1010           0 :     return xChild;
    1011             : }
    1012             : 
    1013             : 
    1014             : 
    1015           0 : void AccessibleDialogWindow::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
    1016             : {
    1017           0 :     OExternalLockGuard aGuard( this );
    1018             : 
    1019           0 :     if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
    1020           0 :         throw IndexOutOfBoundsException();
    1021             : 
    1022           0 :     if ( m_pDialogWindow )
    1023             :     {
    1024           0 :         if (DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj)
    1025             :         {
    1026           0 :             SdrView& rView = m_pDialogWindow->GetView();
    1027           0 :             SdrPageView* pPgView = rView.GetSdrPageView();
    1028           0 :             if (pPgView)
    1029           0 :                 rView.MarkObj( pDlgEdObj, pPgView, true );
    1030             :         }
    1031           0 :     }
    1032           0 : }
    1033             : 
    1034             : 
    1035             : 
    1036             : } // namespace basctl
    1037             : 
    1038             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10