LCOV - code coverage report
Current view: top level - sw/source/core/access - accdoc.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 94 457 20.6 %
Date: 2014-04-11 Functions: 18 43 41.9 %
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 <vcl/window.hxx>
      21             : #include <rootfrm.hxx>
      22             : 
      23             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      24             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      25             : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
      26             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      27             : #include <unotools/accessiblestatesethelper.hxx>
      28             : #include <sfx2/viewsh.hxx>
      29             : #include <osl/mutex.hxx>
      30             : #include <vcl/svapp.hxx>
      31             : #include <comphelper/servicehelper.hxx>
      32             : #include <cppuhelper/supportsservice.hxx>
      33             : #include <viewsh.hxx>
      34             : #include <doc.hxx>
      35             : #include <accmap.hxx>
      36             : #include <accdoc.hxx>
      37             : #include "access.hrc"
      38             : #include <pagefrm.hxx>
      39             : 
      40             : #include <editeng/brushitem.hxx>
      41             : #include <swatrset.hxx>
      42             : #include <frmatr.hxx>
      43             : #include "unostyle.hxx"
      44             : #include "viewsh.hxx"
      45             : #include "docsh.hxx"
      46             : #include <crsrsh.hxx>
      47             : #include "fesh.hxx"
      48             : #include <fmtclds.hxx>
      49             : #include <flyfrm.hxx>
      50             : #include <colfrm.hxx>
      51             : #include <txtfrm.hxx>
      52             : #include <sectfrm.hxx>
      53             : #include <section.hxx>
      54             : #include <svx/unoapi.hxx>
      55             : #include <swmodule.hxx>
      56             : #include <svtools/colorcfg.hxx>
      57             : 
      58             : #include <fmtanchr.hxx>
      59             : #include <viewimp.hxx>
      60             : #include <dview.hxx>
      61             : #include <dcontact.hxx>
      62             : #include <svx/svdmark.hxx>
      63             : const sal_Char sServiceName[] = "com.sun.star.text.AccessibleTextDocumentView";
      64             : const sal_Char sImplementationName[] = "com.sun.star.comp.Writer.SwAccessibleDocumentView";
      65             : 
      66             : using namespace ::com::sun::star;
      67             : using namespace ::com::sun::star::accessibility;
      68             : 
      69             : using lang::IndexOutOfBoundsException;
      70             : 
      71             : // SwAccessibleDocumentBase: base class for SwAccessibleDocument and
      72             : // SwAccessiblePreview
      73             : 
      74          12 : SwAccessibleDocumentBase::SwAccessibleDocumentBase ( SwAccessibleMap *_pMap ) :
      75             :     SwAccessibleContext( _pMap, AccessibleRole::DOCUMENT_TEXT,
      76          12 :                          _pMap->GetShell()->GetLayout() ),
      77             :     mxParent( _pMap->GetShell()->GetWin()->GetAccessibleParentWindow()->GetAccessible() ),
      78          12 :     mpChildWin( 0 )
      79             : {
      80          12 : }
      81             : 
      82          12 : SwAccessibleDocumentBase::~SwAccessibleDocumentBase()
      83             : {
      84          12 : }
      85             : 
      86          19 : void SwAccessibleDocumentBase::SetVisArea()
      87             : {
      88          19 :     SolarMutexGuard aGuard;
      89             : 
      90          19 :     SwRect aOldVisArea( GetVisArea() );
      91          19 :     const SwRect& rNewVisArea = GetMap()->GetVisArea();
      92          19 :     if( aOldVisArea != rNewVisArea )
      93             :     {
      94          19 :         SwAccessibleFrame::SetVisArea( GetMap()->GetVisArea() );
      95             :         // #i58139# - showing state of document view needs also be updated.
      96             :         // Thus, call method <Scrolled(..)> instead of <ChildrenScrolled(..)>
      97             :         // ChildrenScrolled( GetFrm(), aOldVisArea );
      98          19 :         Scrolled( aOldVisArea );
      99          19 :     }
     100          19 : }
     101             : 
     102           0 : void SwAccessibleDocumentBase::AddChild( Window *pWin, sal_Bool bFireEvent )
     103             : {
     104           0 :     SolarMutexGuard aGuard;
     105             : 
     106             :     OSL_ENSURE( !mpChildWin, "only one child window is supported" );
     107           0 :     if( !mpChildWin )
     108             :     {
     109           0 :         mpChildWin = pWin;
     110             : 
     111           0 :         if( bFireEvent )
     112             :         {
     113           0 :             AccessibleEventObject aEvent;
     114           0 :             aEvent.EventId = AccessibleEventId::CHILD;
     115           0 :             aEvent.NewValue <<= mpChildWin->GetAccessible();
     116           0 :             FireAccessibleEvent( aEvent );
     117             :         }
     118           0 :     }
     119           0 : }
     120             : 
     121           0 : void SwAccessibleDocumentBase::RemoveChild( Window *pWin )
     122             : {
     123           0 :     SolarMutexGuard aGuard;
     124             : 
     125             :     OSL_ENSURE( !mpChildWin || pWin == mpChildWin, "invalid child window to remove" );
     126           0 :     if( mpChildWin && pWin == mpChildWin )
     127             :     {
     128           0 :         AccessibleEventObject aEvent;
     129           0 :         aEvent.EventId = AccessibleEventId::CHILD;
     130           0 :         aEvent.OldValue <<= mpChildWin->GetAccessible();
     131           0 :         FireAccessibleEvent( aEvent );
     132             : 
     133           0 :         mpChildWin = 0;
     134           0 :     }
     135           0 : }
     136             : 
     137          34 : sal_Int32 SAL_CALL SwAccessibleDocumentBase::getAccessibleChildCount( void )
     138             :         throw (uno::RuntimeException, std::exception)
     139             : {
     140          34 :     SolarMutexGuard aGuard;
     141             : 
     142             :     // CHECK_FOR_DEFUNC is called by parent
     143             : 
     144          34 :     sal_Int32 nChildren = SwAccessibleContext::getAccessibleChildCount();
     145          34 :     if( !IsDisposing() && mpChildWin )
     146           0 :         nChildren++;
     147             : 
     148          34 :     return nChildren;
     149             : }
     150             : 
     151             : uno::Reference< XAccessible> SAL_CALL
     152          20 :     SwAccessibleDocumentBase::getAccessibleChild( sal_Int32 nIndex )
     153             :         throw (uno::RuntimeException,
     154             :                 lang::IndexOutOfBoundsException, std::exception)
     155             : {
     156          20 :     SolarMutexGuard aGuard;
     157             : 
     158          20 :     if( mpChildWin  )
     159             :     {
     160           0 :         CHECK_FOR_DEFUNC( XAccessibleContext )
     161           0 :         if ( nIndex == GetChildCount( *(GetMap()) ) )
     162             :         {
     163           0 :             return mpChildWin->GetAccessible();
     164             :         }
     165             :     }
     166             : 
     167          20 :     return SwAccessibleContext::getAccessibleChild( nIndex );
     168             : }
     169             : 
     170          14 : uno::Reference< XAccessible> SAL_CALL SwAccessibleDocumentBase::getAccessibleParent (void)
     171             :         throw (uno::RuntimeException, std::exception)
     172             : {
     173          14 :     return mxParent;
     174             : }
     175             : 
     176           0 : sal_Int32 SAL_CALL SwAccessibleDocumentBase::getAccessibleIndexInParent (void)
     177             :         throw (uno::RuntimeException, std::exception)
     178             : {
     179           0 :     SolarMutexGuard aGuard;
     180             : 
     181           0 :     uno::Reference < XAccessibleContext > xAcc( mxParent->getAccessibleContext() );
     182           0 :     uno::Reference < XAccessible > xThis( this );
     183           0 :     sal_Int32 nCount = xAcc->getAccessibleChildCount();
     184             : 
     185           0 :     for( sal_Int32 i=0; i < nCount; i++ )
     186             :     {
     187             :         try
     188             :         {
     189           0 :             if( xAcc->getAccessibleChild( i ) == xThis )
     190           0 :                 return i;
     191             :         }
     192           0 :         catch(::com::sun::star::lang::IndexOutOfBoundsException e)
     193             :         {
     194           0 :             return -1L;
     195             :         }
     196             :     }
     197           0 :     return -1L;
     198             : }
     199             : 
     200          14 : OUString SAL_CALL SwAccessibleDocumentBase::getAccessibleDescription (void)
     201             :     throw (uno::RuntimeException, std::exception)
     202             : {
     203          14 :     return GetResource( STR_ACCESS_DOC_DESC );
     204             : }
     205             : 
     206          14 : OUString SAL_CALL SwAccessibleDocumentBase::getAccessibleName (void)
     207             :         throw (::com::sun::star::uno::RuntimeException, std::exception)
     208             : {
     209          14 :     SolarMutexGuard g;
     210             : 
     211          14 :     OUString sAccName = GetResource( STR_ACCESS_DOC_WORDPROCESSING );
     212          14 :     SwDoc *pDoc = GetMap() ? GetShell()->GetDoc() : 0;
     213          14 :     if ( pDoc )
     214             :     {
     215          14 :         OUString sFileName = pDoc->getDocAccTitle();
     216          14 :         if ( sFileName.isEmpty() )
     217             :         {
     218          14 :             SwDocShell* pDocSh = pDoc->GetDocShell();
     219          14 :             if ( pDocSh )
     220             :             {
     221          14 :                 sFileName = pDocSh->GetTitle( SFX_TITLE_APINAME );
     222             :             }
     223             :         }
     224          28 :         OUString sReadOnly;
     225          14 :         if(pDoc->getDocReadOnly())
     226             :         {
     227           0 :             sReadOnly = GetResource( STR_ACCESS_DOC_WORDPROCESSING_READONLY );
     228             :         }
     229             : 
     230          14 :         if ( !sFileName.isEmpty() )
     231             :         {
     232          14 :             sAccName = sFileName + sReadOnly + " - " + sAccName;
     233          14 :         }
     234             :     }
     235             : 
     236          14 :     return sAccName;
     237             : }
     238             : 
     239           0 : awt::Rectangle SAL_CALL SwAccessibleDocumentBase::getBounds()
     240             :         throw (uno::RuntimeException, std::exception)
     241             : {
     242             :     try
     243             :     {
     244           0 :         SolarMutexGuard aGuard;
     245             : 
     246           0 :         Window *pWin = GetWindow();
     247             : 
     248           0 :         CHECK_FOR_WINDOW( XAccessibleComponent, pWin )
     249             : 
     250           0 :         Rectangle aPixBounds( pWin->GetWindowExtentsRelative( pWin->GetAccessibleParentWindow() ) );
     251           0 :         awt::Rectangle aBox( aPixBounds.Left(), aPixBounds.Top(),
     252           0 :                              aPixBounds.GetWidth(), aPixBounds.GetHeight() );
     253             : 
     254           0 :         return aBox;
     255             :     }
     256           0 :     catch(::com::sun::star::lang::IndexOutOfBoundsException e)
     257             :     {
     258           0 :         return awt::Rectangle();
     259             :     }
     260             : }
     261             : 
     262           0 : awt::Point SAL_CALL SwAccessibleDocumentBase::getLocation()
     263             :         throw (uno::RuntimeException, std::exception)
     264             : {
     265           0 :     SolarMutexGuard aGuard;
     266             : 
     267           0 :     Window *pWin = GetWindow();
     268             : 
     269           0 :     CHECK_FOR_WINDOW( XAccessibleComponent, pWin )
     270             : 
     271           0 :     Point aPixPos( pWin->GetWindowExtentsRelative( pWin->GetAccessibleParentWindow() ).TopLeft() );
     272           0 :     awt::Point aLoc( aPixPos.getX(), aPixPos.getY() );
     273             : 
     274           0 :     return aLoc;
     275             : }
     276             : 
     277           2 : ::com::sun::star::awt::Point SAL_CALL SwAccessibleDocumentBase::getLocationOnScreen()
     278             :         throw (uno::RuntimeException, std::exception)
     279             : {
     280           2 :     SolarMutexGuard aGuard;
     281             : 
     282           2 :     Window *pWin = GetWindow();
     283             : 
     284           2 :     CHECK_FOR_WINDOW( XAccessibleComponent, pWin )
     285             : 
     286           2 :     Point aPixPos( pWin->GetWindowExtentsRelative( 0 ).TopLeft() );
     287           2 :     awt::Point aLoc( aPixPos.getX(), aPixPos.getY() );
     288             : 
     289           2 :     return aLoc;
     290             : }
     291             : 
     292           0 : ::com::sun::star::awt::Size SAL_CALL SwAccessibleDocumentBase::getSize()
     293             :         throw (uno::RuntimeException, std::exception)
     294             : {
     295           0 :     SolarMutexGuard aGuard;
     296             : 
     297           0 :     Window *pWin = GetWindow();
     298             : 
     299           0 :     CHECK_FOR_WINDOW( XAccessibleComponent, pWin )
     300             : 
     301           0 :     Size aPixSize( pWin->GetWindowExtentsRelative( 0 ).GetSize() );
     302           0 :     awt::Size aSize( aPixSize.Width(), aPixSize.Height() );
     303             : 
     304           0 :     return aSize;
     305             : }
     306             : 
     307           0 : sal_Bool SAL_CALL SwAccessibleDocumentBase::containsPoint(
     308             :             const awt::Point& aPoint )
     309             :         throw (uno::RuntimeException, std::exception)
     310             : {
     311           0 :     SolarMutexGuard aGuard;
     312             : 
     313           0 :     Window *pWin = GetWindow();
     314             : 
     315           0 :     CHECK_FOR_WINDOW( XAccessibleComponent, pWin )
     316             : 
     317           0 :     Rectangle aPixBounds( pWin->GetWindowExtentsRelative( 0 ) );
     318           0 :     aPixBounds.Move(-aPixBounds.Left(), -aPixBounds.Top());
     319             : 
     320           0 :     Point aPixPoint( aPoint.X, aPoint.Y );
     321           0 :     return aPixBounds.IsInside( aPixPoint );
     322             : }
     323             : 
     324           0 : uno::Reference< XAccessible > SAL_CALL SwAccessibleDocumentBase::getAccessibleAtPoint(
     325             :                 const awt::Point& aPoint )
     326             :         throw (uno::RuntimeException, std::exception)
     327             : {
     328           0 :     SolarMutexGuard aGuard;
     329             : 
     330           0 :     if( mpChildWin  )
     331             :     {
     332           0 :         CHECK_FOR_DEFUNC( XAccessibleComponent )
     333             : 
     334           0 :         Window *pWin = GetWindow();
     335           0 :         CHECK_FOR_WINDOW( XAccessibleComponent, pWin )
     336             : 
     337           0 :         Point aPixPoint( aPoint.X, aPoint.Y ); // px rel to window
     338           0 :         if( mpChildWin->GetWindowExtentsRelative( pWin ).IsInside( aPixPoint ) )
     339           0 :             return mpChildWin->GetAccessible();
     340             :     }
     341             : 
     342           0 :     return SwAccessibleContext::getAccessibleAtPoint( aPoint );
     343             : }
     344             : 
     345             : // SwAccessibeDocument
     346             : 
     347          12 : void SwAccessibleDocument::GetStates(
     348             :         ::utl::AccessibleStateSetHelper& rStateSet )
     349             : {
     350          12 :     SwAccessibleContext::GetStates( rStateSet );
     351             : 
     352             :     // MULTISELECTABLE
     353          12 :     rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE );
     354          12 :     rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS );
     355          12 : }
     356             : 
     357          12 : SwAccessibleDocument::SwAccessibleDocument ( SwAccessibleMap* pInitMap ) :
     358             :     SwAccessibleDocumentBase( pInitMap ),
     359          12 :     maSelectionHelper( *this )
     360             : {
     361          12 :     SetName( GetResource( STR_ACCESS_DOC_NAME ) );
     362          12 :     Window *pWin = pInitMap->GetShell()->GetWin();
     363          12 :     if( pWin )
     364             :     {
     365          12 :         pWin->AddChildEventListener( LINK( this, SwAccessibleDocument, WindowChildEventListener ));
     366          12 :         sal_uInt16 nCount =   pWin->GetChildCount();
     367          12 :         for( sal_uInt16 i=0; i < nCount; i++ )
     368             :         {
     369           0 :             Window* pChildWin = pWin->GetChild( i );
     370           0 :             if( pChildWin &&
     371           0 :                 AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
     372           0 :                 AddChild( pChildWin, sal_False );
     373             :         }
     374             :     }
     375          12 : }
     376             : 
     377          36 : SwAccessibleDocument::~SwAccessibleDocument()
     378             : {
     379          12 :     Window *pWin = GetMap() ? GetMap()->GetShell()->GetWin() : 0;
     380          12 :     if( pWin )
     381           0 :         pWin->RemoveChildEventListener( LINK( this, SwAccessibleDocument, WindowChildEventListener ));
     382          24 : }
     383             : 
     384          12 : void SwAccessibleDocument::Dispose( sal_Bool bRecursive )
     385             : {
     386             :     OSL_ENSURE( GetFrm() && GetMap(), "already disposed" );
     387             : 
     388          12 :     Window *pWin = GetMap() ? GetMap()->GetShell()->GetWin() : 0;
     389          12 :     if( pWin )
     390          12 :         pWin->RemoveChildEventListener( LINK( this, SwAccessibleDocument, WindowChildEventListener ));
     391          12 :     SwAccessibleContext::Dispose( bRecursive );
     392          12 : }
     393             : 
     394          86 : IMPL_LINK( SwAccessibleDocument, WindowChildEventListener, VclSimpleEvent*, pEvent )
     395             : {
     396             :     OSL_ENSURE( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" );
     397          43 :     if ( pEvent && pEvent->ISA( VclWindowEvent ) )
     398             :     {
     399          43 :         VclWindowEvent *pVclEvent = static_cast< VclWindowEvent * >( pEvent );
     400             :         OSL_ENSURE( pVclEvent->GetWindow(), "Window???" );
     401          43 :         switch ( pVclEvent->GetId() )
     402             :         {
     403             :         case VCLEVENT_WINDOW_SHOW:  // send create on show for direct accessible children
     404             :             {
     405           0 :                 Window* pChildWin = static_cast< Window* >( pVclEvent->GetData() );
     406           0 :                 if( pChildWin && AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
     407             :                 {
     408           0 :                     AddChild( pChildWin );
     409             :                 }
     410             :             }
     411           0 :             break;
     412             :         case VCLEVENT_WINDOW_HIDE:  // send destroy on hide for direct accessible children
     413             :             {
     414          12 :                 Window* pChildWin = static_cast< Window* >( pVclEvent->GetData() );
     415          12 :                 if( pChildWin && AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
     416             :                 {
     417           0 :                     RemoveChild( pChildWin );
     418             :                 }
     419             :             }
     420          12 :             break;
     421             :         case VCLEVENT_OBJECT_DYING:  // send destroy on hide for direct accessible children
     422             :             {
     423           0 :                 Window* pChildWin = pVclEvent->GetWindow();
     424           0 :                 if( pChildWin && AccessibleRole::EMBEDDED_OBJECT == pChildWin->GetAccessibleRole() )
     425             :                 {
     426           0 :                     RemoveChild( pChildWin );
     427             :                 }
     428             :             }
     429           0 :             break;
     430             :         }
     431             :     }
     432          43 :     return 0;
     433             : }
     434             : 
     435           0 : OUString SAL_CALL SwAccessibleDocument::getImplementationName()
     436             :         throw( uno::RuntimeException, std::exception )
     437             : {
     438           0 :     return OUString(sImplementationName);
     439             : }
     440             : 
     441           0 : sal_Bool SAL_CALL SwAccessibleDocument::supportsService(const OUString& sTestServiceName)
     442             :     throw (uno::RuntimeException, std::exception)
     443             : {
     444           0 :     return cppu::supportsService(this, sTestServiceName);
     445             : }
     446             : 
     447           0 : uno::Sequence< OUString > SAL_CALL SwAccessibleDocument::getSupportedServiceNames()
     448             :         throw( uno::RuntimeException, std::exception )
     449             : {
     450           0 :     uno::Sequence< OUString > aRet(2);
     451           0 :     OUString* pArray = aRet.getArray();
     452           0 :     pArray[0] = OUString( sServiceName );
     453           0 :     pArray[1] = OUString( sAccessibleServiceName );
     454           0 :     return aRet;
     455             : }
     456             : 
     457             : // XInterface
     458             : 
     459         206 : uno::Any SwAccessibleDocument::queryInterface(
     460             :     const uno::Type& rType )
     461             :     throw ( uno::RuntimeException, std::exception )
     462             : {
     463         206 :     uno::Any aRet;
     464         206 :     if ( rType == ::getCppuType( static_cast< uno::Reference< XAccessibleSelection > * >( 0 ) ) )
     465             :     {
     466           0 :         uno::Reference<XAccessibleSelection> aSelect = this;
     467           0 :         aRet <<= aSelect;
     468             :     }
     469             :     //Add XEventListener interface support.
     470         206 :     else if ( (rType == ::getCppuType((uno::Reference<com::sun::star::document::XEventListener> *)NULL)) )
     471             :     {
     472           0 :         uno::Reference<com::sun::star::document::XEventListener> aSelect = this;
     473           0 :         aRet <<= aSelect;
     474             :     }
     475         206 :     else  if ( rType == ::getCppuType((uno::Reference<XAccessibleExtendedAttributes> *)NULL) )
     476             :     {
     477           0 :         uno::Reference<XAccessibleExtendedAttributes> aAttribute = this;
     478           0 :         aRet <<= aAttribute;
     479             :     }
     480         206 :     else if(rType == ::getCppuType((uno::Reference<XAccessibleGetAccFlowTo> *)NULL) )
     481             :     {
     482           0 :         uno::Reference<XAccessibleGetAccFlowTo> AccFlowTo = this;
     483           0 :         aRet <<= AccFlowTo;
     484             :     }
     485             :     else
     486         206 :         aRet = SwAccessibleContext::queryInterface( rType );
     487         206 :     return aRet;
     488             : }
     489             : 
     490             : // XTypeProvider
     491           0 : uno::Sequence< uno::Type > SAL_CALL SwAccessibleDocument::getTypes()
     492             :     throw(uno::RuntimeException, std::exception)
     493             : {
     494           0 :     uno::Sequence< uno::Type > aTypes( SwAccessibleDocumentBase::getTypes() );
     495             : 
     496           0 :     sal_Int32 nIndex = aTypes.getLength();
     497             :     //Reset types memory alloc
     498             :     //aTypes.realloc( nIndex + 1 );
     499           0 :     aTypes.realloc( nIndex + 2 );
     500             : 
     501           0 :     uno::Type* pTypes = aTypes.getArray();
     502           0 :     pTypes[nIndex] = ::getCppuType( static_cast< uno::Reference< XAccessibleSelection > * >( 0 ) );
     503             :     //Add XEventListener interface support.
     504           0 :     pTypes[nIndex + 1 ] = ::getCppuType( static_cast< uno::Reference< com::sun::star::document::XEventListener > * >( 0 ) );
     505           0 :     return aTypes;
     506             : }
     507             : 
     508           0 : uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleDocument::getImplementationId()
     509             :         throw(uno::RuntimeException, std::exception)
     510             : {
     511           0 :     return css::uno::Sequence<sal_Int8>();
     512             : }
     513             : 
     514             : // XAccessibleSelection
     515             : 
     516           0 : void SwAccessibleDocument::selectAccessibleChild(
     517             :     sal_Int32 nChildIndex )
     518             :     throw ( lang::IndexOutOfBoundsException,
     519             :             uno::RuntimeException, std::exception )
     520             : {
     521           0 :     maSelectionHelper.selectAccessibleChild(nChildIndex);
     522           0 : }
     523             : 
     524           0 : sal_Bool SwAccessibleDocument::isAccessibleChildSelected(
     525             :     sal_Int32 nChildIndex )
     526             :     throw ( lang::IndexOutOfBoundsException,
     527             :             uno::RuntimeException, std::exception )
     528             : {
     529           0 :     return maSelectionHelper.isAccessibleChildSelected(nChildIndex);
     530             : }
     531             : 
     532           0 : void SwAccessibleDocument::clearAccessibleSelection(  )
     533             :     throw ( uno::RuntimeException, std::exception )
     534             : {
     535           0 :     maSelectionHelper.clearAccessibleSelection();
     536           0 : }
     537             : 
     538           0 : void SwAccessibleDocument::selectAllAccessibleChildren(  )
     539             :     throw ( uno::RuntimeException, std::exception )
     540             : {
     541           0 :     maSelectionHelper.selectAllAccessibleChildren();
     542           0 : }
     543             : 
     544           0 : sal_Int32 SwAccessibleDocument::getSelectedAccessibleChildCount(  )
     545             :     throw ( uno::RuntimeException, std::exception )
     546             : {
     547           0 :     return maSelectionHelper.getSelectedAccessibleChildCount();
     548             : }
     549             : 
     550           0 : uno::Reference<XAccessible> SwAccessibleDocument::getSelectedAccessibleChild(
     551             :     sal_Int32 nSelectedChildIndex )
     552             :     throw ( lang::IndexOutOfBoundsException,
     553             :             uno::RuntimeException, std::exception)
     554             : {
     555           0 :     return maSelectionHelper.getSelectedAccessibleChild(nSelectedChildIndex);
     556             : }
     557             : 
     558             : // index has to be treated as global child index.
     559           0 : void SwAccessibleDocument::deselectAccessibleChild(
     560             :     sal_Int32 nChildIndex )
     561             :     throw ( lang::IndexOutOfBoundsException,
     562             :             uno::RuntimeException, std::exception )
     563             : {
     564           0 :     maSelectionHelper.deselectAccessibleChild( nChildIndex );
     565           0 : }
     566             : 
     567             : //Implement XEventListener interfaces
     568           0 : void SAL_CALL SwAccessibleDocument::notifyEvent( const ::com::sun::star::document::EventObject& Event )
     569             :             throw (::com::sun::star::uno::RuntimeException, std::exception)
     570             : {
     571           0 :     SolarMutexGuard g;
     572             : 
     573           0 :     if ( Event.EventName.equalsAscii( "FirstPageShows" ) )
     574             :     {
     575           0 :         FireStateChangedEvent( AccessibleStateType::FOCUSED,sal_True );
     576             :     }
     577           0 :     else if ( Event.EventName.equalsAscii( "LoadFinished" ) )
     578             :     {
     579             :         // IA2 CWS. MT: OFFSCREEN == !SHOWING, should stay consistent
     580             :         // FireStateChangedEvent( AccessibleStateType::OFFSCREEN,sal_True );
     581             :         // MT: LoadFinished => Why not SHOWING == TRUE?
     582           0 :         FireStateChangedEvent( AccessibleStateType::SHOWING,sal_False );
     583             :     }
     584           0 :     else if ( Event.EventName.equalsAscii( "FormatFinished" ) )
     585             :     {
     586           0 :         FireStateChangedEvent( AccessibleStateType::BUSY,sal_False );
     587             :         // FireStateChangedEvent( AccessibleStateType::OFFSCREEN,sal_False );
     588           0 :         FireStateChangedEvent( AccessibleStateType::SHOWING,sal_True );
     589             :     }
     590             :     else
     591             :     {
     592           0 :         isIfAsynLoad = sal_False;
     593           0 :     }
     594           0 : }
     595             : 
     596           0 : void SAL_CALL SwAccessibleDocument::disposing( const ::com::sun::star::lang::EventObject& )
     597             :             throw (::com::sun::star::uno::RuntimeException, std::exception)
     598             : {
     599           0 : }
     600             : 
     601           0 : uno::Any SAL_CALL SwAccessibleDocument::getExtendedAttributes()
     602             :     throw (::com::sun::star::lang::IndexOutOfBoundsException,
     603             :            ::com::sun::star::uno::RuntimeException,
     604             :            std::exception)
     605             : {
     606           0 :     SolarMutexGuard g;
     607             : 
     608           0 :     uno::Any anyAtrribute;
     609           0 :     SwDoc *pDoc = GetMap() ? GetShell()->GetDoc() : 0;
     610             : 
     611           0 :     if (!pDoc)
     612           0 :         return anyAtrribute;
     613           0 :     SwCrsrShell* pCrsrShell = GetCrsrShell();
     614           0 :     if( !pCrsrShell )
     615           0 :         return anyAtrribute;
     616             : 
     617           0 :     SwFEShell* pFEShell = pCrsrShell->ISA( SwFEShell )
     618             :                                 ? static_cast<SwFEShell*>( pCrsrShell )
     619           0 :                             : 0;
     620           0 :     OUString sAttrName;
     621           0 :     OUString sValue;
     622             :     sal_uInt16 nPage, nLogPage;
     623           0 :     OUString sDisplay;
     624             : 
     625           0 :     if( pFEShell )
     626             :     {
     627           0 :         pFEShell->GetPageNumber(-1,sal_True,nPage,nLogPage,sDisplay);
     628           0 :         sAttrName = "page-name:";
     629             : 
     630           0 :         sValue = sAttrName + sDisplay ;
     631           0 :         sAttrName = ";page-number:";
     632           0 :         sValue += sAttrName;
     633           0 :         sValue += OUString::number( nPage ) ;
     634           0 :         sAttrName = ";total-pages:";
     635           0 :         sValue += sAttrName;
     636           0 :         sValue += OUString::number( pCrsrShell->GetPageCnt() ) ;
     637           0 :         sValue += ";";
     638             : 
     639           0 :         sAttrName = "line-number:";
     640             : 
     641           0 :         SwCntntFrm* pCurrFrm = pCrsrShell->GetCurrFrm();
     642           0 :         SwPageFrm* pCurrPage=((SwFrm*)pCurrFrm)->FindPageFrm();
     643           0 :         sal_uLong nLineNum = 0;
     644           0 :         SwTxtFrm* pTxtFrm = NULL;
     645           0 :         SwTxtFrm* pCurrTxtFrm = NULL;
     646           0 :         pTxtFrm = static_cast< SwTxtFrm* >(static_cast< SwPageFrm* > (pCurrPage)->ContainsCntnt());
     647           0 :         if (pCurrFrm->IsInFly())//such as, graphic,chart
     648             :         {
     649           0 :             SwFlyFrm *pFlyFrm = pCurrFrm->FindFlyFrm();
     650           0 :             const SwFmtAnchor& rAnchor = pFlyFrm->GetFmt()->GetAnchor();
     651           0 :             RndStdIds eAnchorId = rAnchor.GetAnchorId();
     652           0 :             if(eAnchorId == FLY_AS_CHAR)
     653             :             {
     654           0 :                 const SwFrm *pSwFrm = pFlyFrm->GetAnchorFrm();
     655           0 :                 if(pSwFrm->IsTxtFrm())
     656           0 :                     pCurrTxtFrm = ((SwTxtFrm*)(pSwFrm));
     657             :             }
     658             :         }
     659             :         else
     660           0 :             pCurrTxtFrm = static_cast< SwTxtFrm* >(pCurrFrm);
     661             :         //check whether the text frame where the Graph/OLE/Frame anchored is in the Header/Footer
     662           0 :         SwFrm* pFrm = pCurrTxtFrm;
     663           0 :         while ( pFrm && !pFrm->IsHeaderFrm() && !pFrm->IsFooterFrm() )
     664           0 :             pFrm = pFrm->GetUpper();
     665           0 :         if ( pFrm )
     666           0 :             pCurrTxtFrm = NULL;
     667             :         //check shape
     668           0 :         if(pCrsrShell->Imp()->GetDrawView())
     669             :         {
     670           0 :             const SdrMarkList &rMrkList = pCrsrShell->Imp()->GetDrawView()->GetMarkedObjectList();
     671           0 :             for ( sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i )
     672             :             {
     673           0 :                 SdrObject *pObj = rMrkList.GetMark(i)->GetMarkedSdrObj();
     674           0 :                 SwFrmFmt* pFmt = ((SwDrawContact*)pObj->GetUserCall())->GetFmt();
     675           0 :                 const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
     676           0 :                 if( FLY_AS_CHAR != rAnchor.GetAnchorId() )
     677           0 :                     pCurrTxtFrm = NULL;
     678             :             }
     679             :         }
     680             :         //calculate line number
     681           0 :         if (pCurrTxtFrm && pTxtFrm)
     682             :         {
     683           0 :             if (!(pCurrTxtFrm->IsInTab() || pCurrTxtFrm->IsInFtn()))
     684             :             {
     685           0 :                 while( pTxtFrm != pCurrTxtFrm )
     686             :                 {
     687             :                     //check header/footer
     688           0 :                     pFrm = pTxtFrm;
     689           0 :                     while ( pFrm && !pFrm->IsHeaderFrm() && !pFrm->IsFooterFrm() )
     690           0 :                         pFrm = pFrm->GetUpper();
     691           0 :                     if ( pFrm )
     692             :                     {
     693           0 :                         pTxtFrm = static_cast< SwTxtFrm*>(pTxtFrm->GetNextCntntFrm());
     694           0 :                         continue;
     695             :                     }
     696           0 :                     if (!(pTxtFrm->IsInTab() || pTxtFrm->IsInFtn() || pTxtFrm->IsInFly()))
     697           0 :                         nLineNum += pTxtFrm->GetThisLines();
     698           0 :                     pTxtFrm = static_cast< SwTxtFrm* >(pTxtFrm ->GetNextCntntFrm());
     699             :                 }
     700           0 :                 SwPaM* pCaret = pCrsrShell->GetCrsr();
     701           0 :                 if (!pCurrTxtFrm->IsEmpty() && pCaret)
     702             :                 {
     703           0 :                     sal_uInt16 nActPos = 0;
     704           0 :                     if (pCurrTxtFrm->IsTxtFrm())
     705             :                     {
     706           0 :                         const SwPosition* pPoint = NULL;
     707           0 :                         if(pCurrTxtFrm->IsInFly())
     708             :                         {
     709           0 :                             SwFlyFrm *pFlyFrm = pCurrTxtFrm->FindFlyFrm();
     710           0 :                             const SwFmtAnchor& rAnchor = pFlyFrm->GetFmt()->GetAnchor();
     711           0 :                             pPoint= rAnchor.GetCntntAnchor();
     712             :                         }
     713             :                         else
     714           0 :                             pPoint = pCaret->GetPoint();
     715           0 :                         nActPos = pPoint->nContent.GetIndex();
     716           0 :                         nLineNum += pCurrTxtFrm->GetLineCount( nActPos );
     717             :                     }
     718             :                     else//graphic, form, shape, etc.
     719             :                     {
     720           0 :                         SwPosition* pPoint =  pCaret->GetPoint();
     721           0 :                         Point aPt = pCrsrShell->_GetCrsr()->GetPtPos();
     722           0 :                         if( pCrsrShell->GetLayout()->GetCrsrOfst( pPoint, aPt/*,* &eTmpState*/ ) )
     723             :                         {
     724           0 :                             nActPos = pPoint->nContent.GetIndex();
     725           0 :                             nLineNum += pCurrTxtFrm->GetLineCount( nActPos );
     726             :                         }
     727             :                     }
     728             :                 }
     729             :                 else
     730           0 :                     ++nLineNum;
     731             :             }
     732             :         }
     733             : 
     734           0 :         sValue += sAttrName;
     735           0 :         sValue += OUString::number( nLineNum ) ;
     736             : 
     737           0 :         sValue += ";";
     738             : 
     739           0 :         SwFrm* pCurrCol=((SwFrm*)pCurrFrm)->FindColFrm();
     740             : 
     741           0 :         sAttrName = "column-number:";
     742           0 :         sValue += sAttrName;
     743             : 
     744           0 :         sal_uInt16 nCurrCol = 1;
     745           0 :         if(pCurrCol!=NULL)
     746             :         {
     747             :             //SwLayoutFrm* pParent = pCurrCol->GetUpper();
     748           0 :             SwFrm* pCurrPageCol=((SwFrm*)pCurrFrm)->FindColFrm();
     749           0 :             while(pCurrPageCol && pCurrPageCol->GetUpper() && pCurrPageCol->GetUpper()->IsPageFrm())
     750             :             {
     751           0 :                 pCurrPageCol = pCurrPageCol->GetUpper();
     752             :             }
     753             : 
     754           0 :             SwLayoutFrm* pParent = (SwLayoutFrm*)(pCurrPageCol->GetUpper());
     755             : 
     756           0 :             if(pParent!=NULL)
     757             :             {
     758           0 :                 SwFrm* pCol = pParent->Lower();
     759           0 :                 while(pCol&&(pCol!=pCurrPageCol))
     760             :                 {
     761           0 :                     pCol = pCol->GetNext();
     762           0 :                     nCurrCol +=1;
     763             :                 }
     764             :             }
     765             :         }
     766           0 :         sValue += OUString::number( nCurrCol ) ;
     767           0 :         sValue += ";";
     768             : 
     769           0 :         sAttrName = "total-columns:";
     770             : 
     771           0 :         const SwFmtCol &rFmtCol=pCurrPage->GetAttrSet()->GetCol();
     772           0 :         sal_uInt16 nColCount=rFmtCol.GetNumCols();
     773           0 :         nColCount = nColCount>0?nColCount:1;
     774           0 :         sValue += sAttrName;
     775           0 :         sValue += OUString::number( nColCount ) ;
     776             : 
     777           0 :         sValue += ";";
     778             : 
     779           0 :         SwSectionFrm* pCurrSctFrm=((SwFrm*)pCurrFrm)->FindSctFrm();
     780           0 :         if(pCurrSctFrm!=NULL && pCurrSctFrm->GetSection()!=NULL )
     781             :         {
     782           0 :             sAttrName = "section-name:";
     783             : 
     784           0 :             sValue += sAttrName;
     785           0 :             OUString sectionName = pCurrSctFrm->GetSection()->GetSectionName();
     786             : 
     787           0 :             sectionName = sectionName.replaceFirst( "\\" , "\\\\" );
     788           0 :             sectionName = sectionName.replaceFirst( "=" , "\\=" );
     789           0 :             sectionName = sectionName.replaceFirst( ";" , "\\;" );
     790           0 :             sectionName = sectionName.replaceFirst( "," , "\\," );
     791           0 :             sectionName = sectionName.replaceFirst( ":" , "\\:" );
     792             : 
     793           0 :             sValue += sectionName;
     794             : 
     795           0 :             sValue += ";";
     796             : 
     797             :             //section-columns-number
     798           0 :             sAttrName = "section-columns-number:";
     799             : 
     800           0 :             nCurrCol = 1;
     801             : 
     802           0 :             if(pCurrCol!=NULL)
     803             :             {
     804           0 :                 SwLayoutFrm* pParent = pCurrCol->GetUpper();
     805           0 :                 if(pParent!=NULL)
     806             :                 {
     807           0 :                     SwFrm* pCol = pParent->Lower();
     808           0 :                     while(pCol&&(pCol!=pCurrCol))
     809             :                     {
     810           0 :                         pCol = pCol->GetNext();
     811           0 :                         nCurrCol +=1;
     812             :                     }
     813             :                 }
     814             :             }
     815           0 :             sValue += sAttrName;
     816           0 :             sValue += OUString::number( nCurrCol ) ;
     817           0 :             sValue += ";";
     818             : 
     819             :             //section-total-columns
     820           0 :             sAttrName = "section-total-columns:";
     821           0 :             const SwFmtCol &rFmtSctCol=pCurrSctFrm->GetAttrSet()->GetCol();
     822           0 :             sal_uInt16 nSctColCount=rFmtSctCol.GetNumCols();
     823           0 :             nSctColCount = nSctColCount>0?nSctColCount:1;
     824           0 :             sValue += sAttrName;
     825           0 :             sValue += OUString::number( nSctColCount ) ;
     826             : 
     827           0 :             sValue += ";";
     828             :         }
     829             : 
     830           0 :         anyAtrribute <<= sValue;
     831             :     }
     832           0 :     return anyAtrribute;
     833             : }
     834             : 
     835           1 : sal_Int32 SAL_CALL SwAccessibleDocument::getBackground()
     836             :         throw (::com::sun::star::uno::RuntimeException, std::exception)
     837             : {
     838           1 :     SolarMutexGuard aGuard;
     839           1 :     return SW_MOD()->GetColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor;
     840             : }
     841             : 
     842             : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >
     843           0 :         SAL_CALL SwAccessibleDocument::get_AccFlowTo(const ::com::sun::star::uno::Any& rAny, sal_Int32 nType)
     844             :         throw (::com::sun::star::uno::RuntimeException,
     845             :                std::exception)
     846             : {
     847           0 :     SolarMutexGuard g;
     848             : 
     849           0 :     const sal_Int32 FORSPELLCHECKFLOWTO = 1;
     850           0 :     const sal_Int32 FORFINDREPLACEFLOWTO = 2;
     851           0 :     SwAccessibleMap* pAccMap = GetMap();
     852           0 :     if ( !pAccMap )
     853             :     {
     854           0 :         return uno::Sequence< uno::Any >();
     855             :     }
     856             : 
     857           0 :     if ( nType == FORSPELLCHECKFLOWTO )
     858             :     {
     859           0 :         uno::Reference< ::com::sun::star::drawing::XShape > xShape;
     860           0 :         rAny >>= xShape;
     861           0 :         if( xShape.is() )
     862             :         {
     863           0 :             SdrObject* pObj = GetSdrObjectFromXShape(xShape);
     864           0 :             if( pObj )
     865             :             {
     866           0 :                 uno::Reference<XAccessible> xAcc = pAccMap->GetContext(pObj, this, sal_False);
     867           0 :                 uno::Reference < XAccessibleSelection > xAccSelection( xAcc, uno::UNO_QUERY );
     868           0 :                 if ( xAccSelection.is() )
     869             :                 {
     870             :                     try
     871             :                     {
     872           0 :                         if ( xAccSelection->getSelectedAccessibleChildCount() )
     873             :                         {
     874           0 :                             uno::Reference < XAccessible > xSel = xAccSelection->getSelectedAccessibleChild( 0 );
     875           0 :                             if ( xSel.is() )
     876             :                             {
     877           0 :                                 uno::Reference < XAccessibleContext > xSelContext( xSel->getAccessibleContext() );
     878           0 :                                 if ( xSelContext.is() )
     879             :                                 {
     880             :                                     //if in sw we find the selected paragraph here
     881           0 :                                     if ( xSelContext->getAccessibleRole() == AccessibleRole::PARAGRAPH )
     882             :                                     {
     883           0 :                                         uno::Sequence<uno::Any> aRet( 1 );
     884           0 :                                         aRet[0] = uno::makeAny( xSel );
     885           0 :                                         return aRet;
     886             :                                     }
     887           0 :                                 }
     888           0 :                             }
     889             :                         }
     890             :                     }
     891           0 :                     catch ( const com::sun::star::lang::IndexOutOfBoundsException& )
     892             :                     {
     893           0 :                         return uno::Sequence< uno::Any >();
     894             :                     }
     895             :                     //end of try...catch
     896           0 :                 }
     897             :             }
     898             :         }
     899             :         else
     900             :         {
     901           0 :             uno::Reference< XAccessible > xAcc = pAccMap->GetCursorContext();
     902           0 :             SwAccessibleContext *pAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() );
     903           0 :             if ( pAccImpl && pAccImpl->getAccessibleRole() == AccessibleRole::PARAGRAPH )
     904             :             {
     905           0 :                 uno::Sequence< uno::Any > aRet(1);
     906           0 :                 aRet[0] = uno::makeAny( xAcc );
     907           0 :                 return aRet;
     908           0 :             }
     909           0 :         }
     910             :     }
     911           0 :     else if ( nType == FORFINDREPLACEFLOWTO )
     912             :     {
     913           0 :         SwCrsrShell* pCrsrShell = GetCrsrShell();
     914           0 :         if ( pCrsrShell )
     915             :         {
     916           0 :             SwPaM *_pStartCrsr = pCrsrShell->GetCrsr(), *__pStartCrsr = _pStartCrsr;
     917           0 :             SwCntntNode* pPrevNode = NULL;
     918           0 :             std::vector<SwFrm*> vFrmList;
     919           0 :             do
     920             :             {
     921           0 :                 if ( _pStartCrsr && _pStartCrsr->HasMark() )
     922             :                 {
     923           0 :                     SwCntntNode* pCntntNode = _pStartCrsr->GetCntntNode();
     924           0 :                     if ( pCntntNode == pPrevNode )
     925             :                     {
     926           0 :                         continue;
     927             :                     }
     928           0 :                     SwFrm* pFrm = pCntntNode ? pCntntNode->getLayoutFrm( pCrsrShell->GetLayout() ) : NULL;
     929           0 :                     if ( pFrm )
     930             :                     {
     931           0 :                         vFrmList.push_back( pFrm );
     932             :                     }
     933             : 
     934           0 :                     pPrevNode = pCntntNode;
     935             :                 }
     936             :             }
     937             : 
     938           0 :             while( _pStartCrsr && ( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != __pStartCrsr) );
     939             : 
     940           0 :             if ( vFrmList.size() )
     941             :             {
     942           0 :                 uno::Sequence< uno::Any > aRet(vFrmList.size());
     943           0 :                 std::vector<SwFrm*>::iterator aIter = vFrmList.begin();
     944           0 :                 for ( sal_Int32 nIndex = 0; aIter != vFrmList.end(); ++aIter, nIndex++ )
     945             :                 {
     946           0 :                     uno::Reference< XAccessible > xAcc = pAccMap->GetContext(*aIter, sal_False);
     947           0 :                     if ( xAcc.is() )
     948             :                     {
     949           0 :                         SwAccessibleContext *pAccImpl = static_cast< SwAccessibleContext *>( xAcc.get() );
     950           0 :                         if ( pAccImpl && pAccImpl->getAccessibleRole() == AccessibleRole::PARAGRAPH )
     951             :                         {
     952           0 :                             aRet[nIndex] = uno::makeAny( xAcc );
     953             :                         }
     954             :                     }
     955           0 :                 }
     956             : 
     957           0 :                 return aRet;
     958           0 :             }
     959             :         }
     960             :     }
     961             : 
     962           0 :     return uno::Sequence< uno::Any >();
     963             : }
     964             : 
     965             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10