1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 32 #include <vos/mutex.hxx> 33 #include <com/sun/star/accessibility/AccessibleRole.hpp> 34 #include <com/sun/star/accessibility/AccessibleStateType.hpp> 35 #include <unotools/accessiblestatesethelper.hxx> 36 #include <rtl/uuid.h> 37 #include <vcl/svapp.hxx> 38 #include <hffrm.hxx> 39 #include "accheaderfooter.hxx" 40 #ifndef _ACCESS_HRC 41 #include "access.hrc" 42 #endif 43 44 using namespace ::com::sun::star; 45 using namespace ::com::sun::star::lang; 46 using namespace ::com::sun::star::uno; 47 using namespace ::com::sun::star::accessibility; 48 using ::rtl::OUString; 49 50 const sal_Char sServiceNameHeader[] = "com.sun.star.text.AccessibleHeaderView"; 51 const sal_Char sServiceNameFooter[] = "com.sun.star.text.AccessibleFooterView"; 52 const sal_Char sImplementationNameHeader[] = "com.sun.star.comp.Writer.SwAccessibleHeaderView"; 53 const sal_Char sImplementationNameFooter[] = "com.sun.star.comp.Writer.SwAccessibleFooterView"; 54 55 SwAccessibleHeaderFooter::SwAccessibleHeaderFooter( 56 SwAccessibleMap* pInitMap, 57 const SwHeaderFrm* pHdFrm ) : 58 SwAccessibleContext( pInitMap, AccessibleRole::HEADER, pHdFrm ) 59 { 60 vos::OGuard aGuard(Application::GetSolarMutex()); 61 62 OUString sArg( OUString::valueOf( (sal_Int32)pHdFrm->GetPhyPageNum() ) ); 63 SetName( GetResource( STR_ACCESS_HEADER_NAME, &sArg ) ); 64 } 65 66 SwAccessibleHeaderFooter::SwAccessibleHeaderFooter( 67 SwAccessibleMap* pInitMap, 68 const SwFooterFrm* pFtFrm ) : 69 SwAccessibleContext( pInitMap, AccessibleRole::FOOTER, pFtFrm ) 70 { 71 vos::OGuard aGuard(Application::GetSolarMutex()); 72 73 OUString sArg( OUString::valueOf( (sal_Int32)pFtFrm->GetPhyPageNum() ) ); 74 SetName( GetResource( STR_ACCESS_FOOTER_NAME, &sArg ) ); 75 } 76 77 SwAccessibleHeaderFooter::~SwAccessibleHeaderFooter() 78 { 79 } 80 81 OUString SAL_CALL SwAccessibleHeaderFooter::getAccessibleDescription (void) 82 throw (uno::RuntimeException) 83 { 84 vos::OGuard aGuard(Application::GetSolarMutex()); 85 86 CHECK_FOR_DEFUNC( XAccessibleContext ) 87 88 sal_uInt16 nResId = AccessibleRole::HEADER == GetRole() 89 ? STR_ACCESS_HEADER_DESC 90 : STR_ACCESS_FOOTER_DESC ; 91 92 OUString sArg( GetFormattedPageNumber() ); 93 94 return GetResource( nResId, &sArg ); 95 } 96 97 OUString SAL_CALL SwAccessibleHeaderFooter::getImplementationName() 98 throw( RuntimeException ) 99 { 100 if( AccessibleRole::HEADER == GetRole() ) 101 return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationNameHeader)); 102 else 103 return OUString(RTL_CONSTASCII_USTRINGPARAM(sImplementationNameFooter)); 104 } 105 106 sal_Bool SAL_CALL SwAccessibleHeaderFooter::supportsService( 107 const ::rtl::OUString& sTestServiceName) 108 throw (uno::RuntimeException) 109 { 110 if( sTestServiceName.equalsAsciiL( sAccessibleServiceName, 111 sizeof(sAccessibleServiceName)-1 ) ) 112 return sal_True; 113 else if( AccessibleRole::HEADER == GetRole() ) 114 return sTestServiceName.equalsAsciiL( sServiceNameHeader, sizeof(sServiceNameHeader)-1 ); 115 else 116 return sTestServiceName.equalsAsciiL( sServiceNameFooter, sizeof(sServiceNameFooter)-1 ); 117 118 } 119 120 Sequence< OUString > SAL_CALL SwAccessibleHeaderFooter::getSupportedServiceNames() 121 throw( uno::RuntimeException ) 122 { 123 Sequence< OUString > aRet(2); 124 OUString* pArray = aRet.getArray(); 125 if( AccessibleRole::HEADER == GetRole() ) 126 pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceNameHeader) ); 127 else 128 pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sServiceNameFooter) ); 129 pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleServiceName) ); 130 return aRet; 131 } 132 133 Sequence< sal_Int8 > SAL_CALL SwAccessibleHeaderFooter::getImplementationId() 134 throw(RuntimeException) 135 { 136 vos::OGuard aGuard(Application::GetSolarMutex()); 137 static Sequence< sal_Int8 > aId( 16 ); 138 static sal_Bool bInit = sal_False; 139 if(!bInit) 140 { 141 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True ); 142 bInit = sal_True; 143 } 144 return aId; 145 } 146