/************************************************************************* * * $RCSfile: accdoc.cxx,v $ * * $Revision: 1.8 $ * * last change: $Author: mib $ $Date: 2002-04-11 13:45:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses * * - GNU Lesser General Public License Version 2.1 * - Sun Industry Standards Source License Version 1.1 * * Sun Microsystems Inc., October, 2000 * * GNU Lesser General Public License Version 2.1 * ============================================= * Copyright 2000 by Sun Microsystems, Inc. * 901 San Antonio Road, Palo Alto, CA 94303, USA * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * * Sun Industry Standards Source License Version 1.1 * ================================================= * The contents of this file are subject to the Sun Industry Standards * Source License Version 1.1 (the "License"); You may not use this file * except in compliance with the License. You may obtain a copy of the * License at http://www.openoffice.org/license.html. * * Software provided under this License is provided on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. * See the License for the specific provisions governing your rights and * obligations concerning the Software. * * The Initial Developer of the Original Code is: Sun Microsystems, Inc. * * Copyright: 2000 by Sun Microsystems, Inc. * * All Rights Reserved. * * Contributor(s): _______________________________________ * * ************************************************************************/ #ifdef PRECOMPILED #include "core_pch.hxx" #endif #ifndef _SV_WINDOW_HXX #include #endif #ifndef _ROOTFRM_HXX #include #endif #pragma hdrstop #ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_ #include #endif #ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_ #include #endif #ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_ #include #endif #ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX_ #include #endif #ifndef _VOS_MUTEX_HXX_ //autogen #include #endif #ifndef _SV_SVAPP_HXX //autogen #include #endif #ifndef _VIEWSH_HXX #include #endif #ifndef _DOC_HXX #include #endif #ifndef _ACCMAP_HXX #include #endif #ifndef _ACCDOC_HXX #include #endif #ifndef _ACCESS_HRC #include "access.hrc" #endif const sal_Char sServiceName[] = "com.sun.star.text.AccessibleTextDocumentView"; const sal_Char sImplementationName[] = "SwAccessibleDocument"; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::drafts::com::sun::star::accessibility; using namespace ::rtl; void SwAccessibleDocument::GetStates( ::utl::AccessibleStateSetHelper& rStateSet ) { SwAccessibleContext::GetStates( rStateSet ); // MULTISELECTABLE rStateSet.AddState( AccessibleStateType::MULTISELECTABLE ); } SwAccessibleDocument::SwAccessibleDocument ( SwAccessibleMap *pMap ) : SwAccessibleContext( pMap, AccessibleRole::DOCUMENT, pMap->GetShell()->GetDoc()->GetRootFrm() ), xParent( pMap->GetShell()->GetWin()->GetParent()->GetAccessible() ) { SetName( GetResource( STR_ACCESS_DOC_NAME ) ); } SwAccessibleDocument::~SwAccessibleDocument() { } void SwAccessibleDocument::SetVisArea() { vos::OGuard aGuard(Application::GetSolarMutex()); SwRect aOldVisArea( GetVisArea() ); const SwRect& rNewVisArea = GetMap()->GetVisArea(); if( aOldVisArea != rNewVisArea ) { SwAccessibleFrame::SetVisArea( GetMap()->GetVisArea() ); ChildrenScrolled( GetFrm(), aOldVisArea ); } } Reference< XAccessible> SAL_CALL SwAccessibleDocument::getAccessibleParent (void) throw (::com::sun::star::uno::RuntimeException) { return xParent; } sal_Int32 SAL_CALL SwAccessibleDocument::getAccessibleIndexInParent (void) throw (::com::sun::star::uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); Reference < XAccessibleContext > xAcc( xParent->getAccessibleContext() ); Reference < XAccessible > xThis( this ); sal_Int32 nCount = xAcc->getAccessibleChildCount(); for( sal_Int32 i=0; i < nCount; i++ ) { if( xAcc->getAccessibleChild( i ) == xThis ) return i; } return -1L; } OUString SAL_CALL SwAccessibleDocument::getAccessibleDescription (void) throw (com::sun::star::uno::RuntimeException) { return GetResource( STR_ACCESS_DOC_DESC ); } awt::Rectangle SAL_CALL SwAccessibleDocument::getBounds() throw (RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); Window *pWin = GetWindow(); CHECK_FOR_WINDOW( XAccessibleComponent, pWin ) Rectangle aPixBounds( pWin->GetWindowExtentsRelative( pWin->GetParent() ) ); awt::Rectangle aBox( aPixBounds.Left(), aPixBounds.Top(), aPixBounds.GetWidth(), aPixBounds.GetHeight() ); return aBox; } awt::Point SAL_CALL SwAccessibleDocument::getLocation() throw (RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); Window *pWin = GetWindow(); CHECK_FOR_WINDOW( XAccessibleComponent, pWin ) Point aPixPos( pWin->GetWindowExtentsRelative( pWin->GetParent() ).TopLeft() ); awt::Point aLoc( aPixPos.X(), aPixPos.Y() ); return aLoc; } ::com::sun::star::awt::Point SAL_CALL SwAccessibleDocument::getLocationOnScreen() throw (RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); Window *pWin = GetWindow(); CHECK_FOR_WINDOW( XAccessibleComponent, pWin ) Point aPixPos( pWin->GetWindowExtentsRelative( 0 ).TopLeft() ); awt::Point aLoc( aPixPos.X(), aPixPos.Y() ); return aLoc; } ::com::sun::star::awt::Size SAL_CALL SwAccessibleDocument::getSize() throw (RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); Window *pWin = GetWindow(); CHECK_FOR_WINDOW( XAccessibleComponent, pWin ) Size aPixSize( pWin->GetWindowExtentsRelative( 0 ).GetSize() ); awt::Size aSize( aPixSize.Width(), aPixSize.Height() ); return aSize; } OUString SAL_CALL SwAccessibleDocument::getImplementationName() throw( RuntimeException ) { return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationName)); } sal_Bool SAL_CALL SwAccessibleDocument::supportsService( const ::rtl::OUString& sTestServiceName) throw (::com::sun::star::uno::RuntimeException) { return sTestServiceName.equalsAsciiL( sServiceName, sizeof(sServiceName)-1 ); } Sequence< OUString > SAL_CALL SwAccessibleDocument::getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ) { Sequence< OUString > aRet(1); OUString* pArray = aRet.getArray(); pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceName) ); return aRet; }