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_comphelper.hxx" 30 #include <comphelper/accessiblecomponenthelper.hxx> 31 32 //......................................................................... 33 namespace comphelper 34 { 35 //......................................................................... 36 37 using namespace ::com::sun::star::uno; 38 using namespace ::com::sun::star::awt; 39 using namespace ::com::sun::star::lang; 40 using namespace ::com::sun::star::accessibility; 41 42 //===================================================================== 43 //= OCommonAccessibleComponent 44 //===================================================================== 45 //--------------------------------------------------------------------- 46 OCommonAccessibleComponent::OCommonAccessibleComponent( ) 47 { 48 } 49 50 //--------------------------------------------------------------------- 51 OCommonAccessibleComponent::OCommonAccessibleComponent( IMutex* _pExternalLock ) 52 :OAccessibleContextHelper( _pExternalLock ) 53 { 54 } 55 56 //--------------------------------------------------------------------- 57 OCommonAccessibleComponent::~OCommonAccessibleComponent( ) 58 { 59 forgetExternalLock(); 60 // this ensures that the lock, which may be already destroyed as part of the derivee, 61 // is not used anymore 62 } 63 64 //-------------------------------------------------------------------- 65 sal_Bool SAL_CALL OCommonAccessibleComponent::containsPoint( const Point& _rPoint ) throw (RuntimeException) 66 { 67 OExternalLockGuard aGuard( this ); 68 Rectangle aBounds( implGetBounds() ); 69 return ( _rPoint.X >= 0 ) 70 && ( _rPoint.Y >= 0 ) 71 && ( _rPoint.X < aBounds.Width ) 72 && ( _rPoint.Y < aBounds.Height ); 73 } 74 75 //-------------------------------------------------------------------- 76 Point SAL_CALL OCommonAccessibleComponent::getLocation( ) throw (RuntimeException) 77 { 78 OExternalLockGuard aGuard( this ); 79 Rectangle aBounds( implGetBounds() ); 80 return Point( aBounds.X, aBounds.Y ); 81 } 82 83 //-------------------------------------------------------------------- 84 Point SAL_CALL OCommonAccessibleComponent::getLocationOnScreen( ) throw (RuntimeException) 85 { 86 OExternalLockGuard aGuard( this ); 87 Rectangle aBounds( implGetBounds() ); 88 89 Point aScreenLoc( 0, 0 ); 90 91 Reference< XAccessibleComponent > xParentComponent( implGetParentContext(), UNO_QUERY ); 92 OSL_ENSURE( xParentComponent.is(), "OCommonAccessibleComponent::getLocationOnScreen: no parent component!" ); 93 if ( xParentComponent.is() ) 94 { 95 Point aParentScreenLoc( xParentComponent->getLocationOnScreen() ); 96 Point aOwnRelativeLoc( getLocation() ); 97 aScreenLoc.X = aParentScreenLoc.X + aOwnRelativeLoc.X; 98 aScreenLoc.Y = aParentScreenLoc.Y + aOwnRelativeLoc.Y; 99 } 100 101 return aScreenLoc; 102 } 103 104 //-------------------------------------------------------------------- 105 Size SAL_CALL OCommonAccessibleComponent::getSize( ) throw (RuntimeException) 106 { 107 OExternalLockGuard aGuard( this ); 108 Rectangle aBounds( implGetBounds() ); 109 return Size( aBounds.Width, aBounds.Height ); 110 } 111 112 //-------------------------------------------------------------------- 113 Rectangle SAL_CALL OCommonAccessibleComponent::getBounds( ) throw (RuntimeException) 114 { 115 OExternalLockGuard aGuard( this ); 116 return implGetBounds(); 117 } 118 119 //===================================================================== 120 //= OAccessibleComponentHelper 121 //===================================================================== 122 //--------------------------------------------------------------------- 123 OAccessibleComponentHelper::OAccessibleComponentHelper( ) 124 { 125 } 126 127 //--------------------------------------------------------------------- 128 OAccessibleComponentHelper::OAccessibleComponentHelper( IMutex* _pExternalLock ) 129 :OCommonAccessibleComponent( _pExternalLock ) 130 { 131 } 132 133 //-------------------------------------------------------------------- 134 IMPLEMENT_FORWARD_XINTERFACE2( OAccessibleComponentHelper, OCommonAccessibleComponent, OAccessibleComponentHelper_Base ) 135 IMPLEMENT_FORWARD_XTYPEPROVIDER2( OAccessibleComponentHelper, OCommonAccessibleComponent, OAccessibleComponentHelper_Base ) 136 // (order matters: the first is the class name, the second is the class doing the ref counting) 137 138 //-------------------------------------------------------------------- 139 sal_Bool SAL_CALL OAccessibleComponentHelper::containsPoint( const Point& _rPoint ) throw (RuntimeException) 140 { 141 return OCommonAccessibleComponent::containsPoint( _rPoint ); 142 } 143 144 //-------------------------------------------------------------------- 145 Point SAL_CALL OAccessibleComponentHelper::getLocation( ) throw (RuntimeException) 146 { 147 return OCommonAccessibleComponent::getLocation( ); 148 } 149 150 //-------------------------------------------------------------------- 151 Point SAL_CALL OAccessibleComponentHelper::getLocationOnScreen( ) throw (RuntimeException) 152 { 153 return OCommonAccessibleComponent::getLocationOnScreen( ); 154 } 155 156 //-------------------------------------------------------------------- 157 Size SAL_CALL OAccessibleComponentHelper::getSize( ) throw (RuntimeException) 158 { 159 return OCommonAccessibleComponent::getSize( ); 160 } 161 162 //-------------------------------------------------------------------- 163 Rectangle SAL_CALL OAccessibleComponentHelper::getBounds( ) throw (RuntimeException) 164 { 165 return OCommonAccessibleComponent::getBounds( ); 166 } 167 168 //===================================================================== 169 //= OAccessibleExtendedComponentHelper 170 //===================================================================== 171 //--------------------------------------------------------------------- 172 OAccessibleExtendedComponentHelper::OAccessibleExtendedComponentHelper( ) 173 { 174 } 175 176 //--------------------------------------------------------------------- 177 OAccessibleExtendedComponentHelper::OAccessibleExtendedComponentHelper( IMutex* _pExternalLock ) 178 :OCommonAccessibleComponent( _pExternalLock ) 179 { 180 } 181 182 //-------------------------------------------------------------------- 183 IMPLEMENT_FORWARD_XINTERFACE2( OAccessibleExtendedComponentHelper, OCommonAccessibleComponent, OAccessibleExtendedComponentHelper_Base ) 184 IMPLEMENT_FORWARD_XTYPEPROVIDER2( OAccessibleExtendedComponentHelper, OCommonAccessibleComponent, OAccessibleExtendedComponentHelper_Base ) 185 // (order matters: the first is the class name, the second is the class doing the ref counting) 186 187 //-------------------------------------------------------------------- 188 sal_Bool SAL_CALL OAccessibleExtendedComponentHelper::containsPoint( const Point& _rPoint ) throw (RuntimeException) 189 { 190 return OCommonAccessibleComponent::containsPoint( _rPoint ); 191 } 192 193 //-------------------------------------------------------------------- 194 Point SAL_CALL OAccessibleExtendedComponentHelper::getLocation( ) throw (RuntimeException) 195 { 196 return OCommonAccessibleComponent::getLocation( ); 197 } 198 199 //-------------------------------------------------------------------- 200 Point SAL_CALL OAccessibleExtendedComponentHelper::getLocationOnScreen( ) throw (RuntimeException) 201 { 202 return OCommonAccessibleComponent::getLocationOnScreen( ); 203 } 204 205 //-------------------------------------------------------------------- 206 Size SAL_CALL OAccessibleExtendedComponentHelper::getSize( ) throw (RuntimeException) 207 { 208 return OCommonAccessibleComponent::getSize( ); 209 } 210 211 //-------------------------------------------------------------------- 212 Rectangle SAL_CALL OAccessibleExtendedComponentHelper::getBounds( ) throw (RuntimeException) 213 { 214 return OCommonAccessibleComponent::getBounds( ); 215 } 216 217 //......................................................................... 218 } // namespace comphelper 219 //......................................................................... 220 221 222