LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/docvw - SidebarTxtControlAcc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 87 0.0 %
Date: 2012-12-27 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 <SidebarTxtControlAcc.hxx>
      21             : 
      22             : #include <SidebarTxtControl.hxx>
      23             : 
      24             : #include <svl/brdcst.hxx>
      25             : #include <toolkit/awt/vclxaccessiblecomponent.hxx>
      26             : #include <editeng/unoedsrc.hxx>
      27             : #include <editeng/unoforou.hxx>
      28             : #include <editeng/unoviwou.hxx>
      29             : #include <editeng/unoedhlp.hxx>
      30             : #include <svx/AccessibleTextHelper.hxx>
      31             : #include <editeng/outliner.hxx>
      32             : 
      33             : 
      34             : namespace sw { namespace sidebarwindows {
      35             : 
      36             : // =============================================================================
      37             : // declaration and implementation of <SvxEditSource>
      38             : // for <::accessibiliy::AccessibleTextHelper> instance
      39             : // =============================================================================
      40             : class SidebarTextEditSource : public SvxEditSource,
      41             :                               public SfxBroadcaster
      42             : {
      43             :     public:
      44             :         SidebarTextEditSource( SidebarTxtControl& rSidebarTxtControl );
      45             :         virtual ~SidebarTextEditSource();
      46             : 
      47             :         virtual SvxEditSource* Clone() const;
      48             : 
      49             :         virtual SvxTextForwarder* GetTextForwarder();
      50             :         virtual SvxViewForwarder* GetViewForwarder();
      51             :         virtual SvxEditViewForwarder* GetEditViewForwarder( sal_Bool bCreate = sal_False );
      52             : 
      53             :         virtual void UpdateData();
      54             : 
      55             :         virtual SfxBroadcaster& GetBroadcaster() const;
      56             :         DECL_LINK( NotifyHdl, EENotify* );
      57             : 
      58             :     private:
      59             :         SidebarTxtControl& mrSidebarTxtControl;
      60             :         SvxOutlinerForwarder mTextForwarder;
      61             :         SvxDrawOutlinerViewForwarder mViewForwarder;
      62             : };
      63             : 
      64           0 : SidebarTextEditSource::SidebarTextEditSource( SidebarTxtControl& rSidebarTxtControl )
      65             :     : SvxEditSource()
      66             :     , mrSidebarTxtControl( rSidebarTxtControl )
      67           0 :     , mTextForwarder( *(rSidebarTxtControl.GetTextView()->GetOutliner()), sal_False )
      68           0 :     , mViewForwarder( *(rSidebarTxtControl.GetTextView()) )
      69             : {
      70           0 :     if ( mrSidebarTxtControl.GetTextView() )
      71             :     {
      72           0 :         mrSidebarTxtControl.GetTextView()->GetOutliner()->SetNotifyHdl( LINK(this, SidebarTextEditSource, NotifyHdl) );
      73             :     }
      74           0 : }
      75             : 
      76           0 : SidebarTextEditSource::~SidebarTextEditSource()
      77             : {
      78           0 :     if ( mrSidebarTxtControl.GetTextView() )
      79             :     {
      80           0 :         mrSidebarTxtControl.GetTextView()->GetOutliner()->SetNotifyHdl( Link() );
      81             :     }
      82           0 : }
      83             : 
      84           0 : SvxEditSource* SidebarTextEditSource::Clone() const
      85             : {
      86           0 :     return new SidebarTextEditSource( mrSidebarTxtControl );
      87             : }
      88             : 
      89           0 : SvxTextForwarder* SidebarTextEditSource::GetTextForwarder()
      90             : {
      91           0 :     return &mTextForwarder;
      92             : }
      93             : 
      94           0 : SvxViewForwarder* SidebarTextEditSource::GetViewForwarder()
      95             : {
      96           0 :     return &mViewForwarder;
      97             : }
      98             : 
      99           0 : SvxEditViewForwarder* SidebarTextEditSource::GetEditViewForwarder( sal_Bool /*bCreate*/ )
     100             : {
     101           0 :     return &mViewForwarder;
     102             : }
     103             : 
     104           0 : void SidebarTextEditSource::UpdateData()
     105             : {
     106             :     // nothing to do
     107           0 : }
     108             : 
     109           0 : SfxBroadcaster& SidebarTextEditSource::GetBroadcaster() const
     110             : {
     111           0 :     return *( const_cast< SidebarTextEditSource* > (this) );
     112             : }
     113             : 
     114           0 : IMPL_LINK(SidebarTextEditSource, NotifyHdl, EENotify*, pNotify)
     115             : {
     116           0 :     if ( pNotify )
     117             :     {
     118           0 :         ::std::auto_ptr< SfxHint > aHint( SvxEditSourceHelper::EENotification2Hint( pNotify ) );
     119             : 
     120           0 :         if( aHint.get() )
     121             :         {
     122           0 :             Broadcast( *aHint.get() );
     123           0 :         }
     124             :     }
     125             : 
     126           0 :     return 0;
     127             : }
     128             : 
     129             : 
     130             : // =============================================================================
     131             : // declaration and implementation of accessible context for <SidebarTxtControl> instance
     132             : // =============================================================================
     133             : class SidebarTxtControlAccessibleContext : public VCLXAccessibleComponent
     134             : {
     135             :     public:
     136             :         explicit SidebarTxtControlAccessibleContext( SidebarTxtControl& rSidebarTxtControl );
     137             :         virtual ~SidebarTxtControlAccessibleContext();
     138             : 
     139             :         virtual sal_Int32 SAL_CALL
     140             :                 getAccessibleChildCount()
     141             :                 throw (::com::sun::star::uno::RuntimeException);
     142             :         virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
     143             :                 getAccessibleChild( sal_Int32 i )
     144             :                 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
     145             : 
     146             :         virtual void SAL_CALL
     147             :                 addAccessibleEventListener (
     148             :                     const ::com::sun::star::uno::Reference<
     149             :                         ::com::sun::star::accessibility::XAccessibleEventListener >& xListener)
     150             :                 throw (::com::sun::star::uno::RuntimeException);
     151             :         virtual void SAL_CALL
     152             :                 removeAccessibleEventListener (
     153             :                     const ::com::sun::star::uno::Reference<
     154             :                         ::com::sun::star::accessibility::XAccessibleEventListener >& xListener)
     155             :                 throw (::com::sun::star::uno::RuntimeException);
     156             : 
     157             :     protected:
     158             :         virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
     159             : 
     160             :     private:
     161             :         SidebarTxtControl& mrSidebarTxtControl;
     162             :         ::accessibility::AccessibleTextHelper* mpAccessibleTextHelper;
     163             : 
     164             :         ::osl::Mutex maMutex;
     165             : 
     166             :         void defunc();
     167             : };
     168             : 
     169           0 : SidebarTxtControlAccessibleContext::SidebarTxtControlAccessibleContext( SidebarTxtControl& rSidebarTxtControl )
     170             :     : VCLXAccessibleComponent( rSidebarTxtControl.GetWindowPeer() )
     171             :     , mrSidebarTxtControl( rSidebarTxtControl )
     172             :     , mpAccessibleTextHelper( 0 )
     173           0 :     , maMutex()
     174             : {
     175             :     ::std::auto_ptr<SvxEditSource> pEditSource(
     176           0 :                         new SidebarTextEditSource( mrSidebarTxtControl ) );
     177           0 :     mpAccessibleTextHelper = new ::accessibility::AccessibleTextHelper( pEditSource );
     178           0 :     mpAccessibleTextHelper->SetEventSource( mrSidebarTxtControl.GetWindowPeer() );
     179           0 : }
     180             : 
     181           0 : SidebarTxtControlAccessibleContext::~SidebarTxtControlAccessibleContext()
     182             : {
     183           0 :     defunc();
     184           0 : }
     185             : 
     186           0 : void SidebarTxtControlAccessibleContext::defunc()
     187             : {
     188           0 :     delete mpAccessibleTextHelper;
     189           0 :     mpAccessibleTextHelper = 0;
     190           0 : }
     191             : 
     192           0 : sal_Int32 SAL_CALL SidebarTxtControlAccessibleContext::getAccessibleChildCount()
     193             :     throw (::com::sun::star::uno::RuntimeException)
     194             : {
     195           0 :     osl::MutexGuard aGuard( maMutex );
     196             : 
     197           0 :     sal_Int32 nChildCount( 0 );
     198             : 
     199           0 :     if ( mpAccessibleTextHelper )
     200             :     {
     201           0 :         nChildCount = mpAccessibleTextHelper->GetChildCount();
     202             :     }
     203             : 
     204           0 :     return nChildCount;
     205             : }
     206             : 
     207           0 : css::uno::Reference< css::accessibility::XAccessible > SAL_CALL SidebarTxtControlAccessibleContext::getAccessibleChild( sal_Int32 i )
     208             :     throw ( css::lang::IndexOutOfBoundsException, css::uno::RuntimeException )
     209             : {
     210           0 :     osl::MutexGuard aGuard( maMutex );
     211             : 
     212           0 :     css::uno::Reference< css::accessibility::XAccessible > xChild;
     213             : 
     214           0 :     if ( mpAccessibleTextHelper )
     215             :     {
     216           0 :         xChild = mpAccessibleTextHelper->GetChild( i );
     217             :     }
     218             : 
     219           0 :     return xChild;
     220             : }
     221             : 
     222           0 : void SAL_CALL SidebarTxtControlAccessibleContext::addAccessibleEventListener (
     223             :     const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener)
     224             :     throw (css::uno::RuntimeException)
     225             : {
     226           0 :     osl::MutexGuard aGuard( maMutex );
     227             : 
     228           0 :     if ( mpAccessibleTextHelper )
     229             :     {
     230           0 :         mpAccessibleTextHelper->AddEventListener(xListener);
     231           0 :     }
     232           0 : }
     233             : 
     234           0 : void SAL_CALL SidebarTxtControlAccessibleContext::removeAccessibleEventListener (
     235             :     const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener)
     236             :     throw (css::uno::RuntimeException)
     237             : {
     238           0 :     osl::MutexGuard aGuard( maMutex );
     239             : 
     240           0 :     if ( mpAccessibleTextHelper )
     241             :     {
     242           0 :         mpAccessibleTextHelper->RemoveEventListener(xListener);
     243           0 :     }
     244           0 : }
     245             : 
     246           0 : void SidebarTxtControlAccessibleContext::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
     247             : {
     248           0 :     if ( mpAccessibleTextHelper )
     249             :     {
     250           0 :         switch ( rVclWindowEvent.GetId() )
     251             :         {
     252             :             case VCLEVENT_OBJECT_DYING:
     253             :             {
     254           0 :                 defunc();
     255             :             }
     256           0 :             break;
     257             :             case VCLEVENT_WINDOW_GETFOCUS:
     258             :             case VCLEVENT_CONTROL_GETFOCUS:
     259             :             {
     260           0 :                 mpAccessibleTextHelper->SetFocus( sal_True );
     261             :             }
     262           0 :             break;
     263             :             case VCLEVENT_WINDOW_LOSEFOCUS:
     264             :             case VCLEVENT_CONTROL_LOSEFOCUS:
     265             :             {
     266           0 :                 mpAccessibleTextHelper->SetFocus( sal_False );
     267             :             }
     268           0 :             break;
     269             :         }
     270             :     }
     271             : 
     272           0 :     VCLXAccessibleComponent::ProcessWindowEvent( rVclWindowEvent );
     273           0 : }
     274             : 
     275             : // =============================================================================
     276             : // implementaion of accessible for <SidebarTxtControl> instance
     277             : // =============================================================================
     278           0 : SidebarTxtControlAccessible::SidebarTxtControlAccessible( SidebarTxtControl& rSidebarTxtControl )
     279             :     : VCLXWindow()
     280           0 :     , mrSidebarTxtControl( rSidebarTxtControl )
     281             : {
     282           0 :     SetWindow( &mrSidebarTxtControl );
     283           0 : }
     284             : 
     285           0 : SidebarTxtControlAccessible::~SidebarTxtControlAccessible()
     286             : {
     287           0 : }
     288             : 
     289           0 : css::uno::Reference< css::accessibility::XAccessibleContext > SidebarTxtControlAccessible::CreateAccessibleContext()
     290             : {
     291             :     SidebarTxtControlAccessibleContext* pAccContext(
     292           0 :                         new SidebarTxtControlAccessibleContext( mrSidebarTxtControl ) );
     293           0 :     css::uno::Reference< css::accessibility::XAccessibleContext > xAcc( pAccContext );
     294           0 :     return xAcc;
     295             : }
     296             : 
     297             : } } // end of namespace sw::sidebarwindows
     298             : 
     299             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10