1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright IBM Corporation 2010. 6 * Copyright 2000, 2010 Oracle and/or its affiliates. 7 * 8 * OpenOffice.org - a multi-platform office productivity suite 9 * 10 * This file is part of OpenOffice.org. 11 * 12 * OpenOffice.org is free software: you can redistribute it and/or modify 13 * it under the terms of the GNU Lesser General Public License version 3 14 * only, as published by the Free Software Foundation. 15 * 16 * OpenOffice.org is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License version 3 for more details 20 * (a copy is included in the LICENSE file that accompanied this code). 21 * 22 * You should have received a copy of the GNU Lesser General Public License 23 * version 3 along with OpenOffice.org. If not, see 24 * <http://www.openoffice.org/license.html> 25 * for a copy of the LGPLv3 License. 26 * 27 ************************************************************************/ 28 29 #include "stdafx.h" 30 #include "AccComponentBase.h" 31 #include <com/sun/star/accessibility/XAccessible.hpp> 32 #include <com/sun/star/accessibility/XAccessibleContext.hpp> 33 #include "MAccessible.h" 34 35 using namespace com::sun::star::accessibility; 36 using namespace com::sun::star::uno; 37 38 ////////////////////////////////////////////////////////////////////// 39 // Construction/Destruction 40 ////////////////////////////////////////////////////////////////////// 41 42 CAccComponentBase::CAccComponentBase() 43 {} 44 45 CAccComponentBase::~CAccComponentBase() 46 {} 47 48 49 /** 50 * Returns the location of the upper left corner of the object's bounding 51 * box relative to the parent. 52 * 53 * @param Location the upper left corner of the object's bounding box. 54 */ 55 STDMETHODIMP CAccComponentBase::get_locationInParent(long *x, long *y) 56 { 57 58 CHECK_ENABLE_INF 59 60 try 61 { 62 if (x == NULL || y == NULL) 63 return E_INVALIDARG; 64 // #CHECK XInterface# 65 if(!pRXComp.is()) 66 return E_FAIL; 67 68 const ::com::sun::star::awt::Point& pt = GetXInterface()->getLocation(); 69 *x = pt.X; 70 *y = pt.Y; 71 return S_OK; 72 } 73 catch(...) 74 { 75 return E_FAIL; 76 } 77 } 78 79 /** 80 * Returns the location of the upper left corner of the object's bounding 81 * box in screen. 82 * 83 * @param Location the upper left corner of the object's bounding 84 * box in screen coordinates. 85 */ 86 STDMETHODIMP CAccComponentBase::get_locationOnScreen(long *x, long *y) 87 { 88 89 CHECK_ENABLE_INF 90 91 try 92 { 93 if (x == NULL || y == NULL) 94 return E_INVALIDARG; 95 // #CHECK XInterface# 96 if(!pRXComp.is()) 97 return E_FAIL; 98 99 const ::com::sun::star::awt::Point& pt = GetXInterface()->getLocationOnScreen(); 100 *x = pt.X; 101 *y = pt.Y; 102 return S_OK; 103 104 } 105 catch(...) 106 { 107 return E_FAIL; 108 } 109 } 110 111 /** 112 * Grabs the focus to this object. 113 * 114 * @param success the boolean result to be returned. 115 */ 116 STDMETHODIMP CAccComponentBase::grabFocus(boolean * success) 117 { 118 119 CHECK_ENABLE_INF 120 121 ENTER_PROTECTED_BLOCK 122 123 if (success == NULL) 124 return E_INVALIDARG; 125 // #CHECK XInterface# 126 if(!pRXComp.is()) 127 { 128 return E_FAIL; 129 } 130 GetXInterface()->grabFocus(); 131 *success = TRUE; 132 133 return S_OK; 134 135 LEAVE_PROTECTED_BLOCK 136 } 137 138 /** 139 * Returns the foreground color of this object. 140 * 141 * @param Color the color of foreground. 142 */ 143 STDMETHODIMP CAccComponentBase::get_foreground(IA2Color * foreground) 144 { 145 146 CHECK_ENABLE_INF 147 148 ENTER_PROTECTED_BLOCK 149 150 if (foreground == NULL) 151 return E_INVALIDARG; 152 // #CHECK XInterface# 153 if(!pRXComp.is()) 154 { 155 return E_FAIL; 156 } 157 *foreground = (long)GetXInterface()->getForeground(); 158 159 return S_OK; 160 161 LEAVE_PROTECTED_BLOCK 162 } 163 164 /** 165 * Returns the background color of this object. 166 * 167 * @param Color the color of background. 168 */ 169 STDMETHODIMP CAccComponentBase::get_background(IA2Color * background) 170 { 171 172 CHECK_ENABLE_INF 173 174 ENTER_PROTECTED_BLOCK 175 176 if (background == NULL) 177 return E_INVALIDARG; 178 // #CHECK XInterface# 179 if(!pRXComp.is()) 180 { 181 return E_FAIL; 182 } 183 *background = (long)GetXInterface()->getBackground(); 184 185 return S_OK; 186 187 LEAVE_PROTECTED_BLOCK 188 } 189 190 /** 191 * Overide of IUNOXWrapper. 192 * 193 * @param pXInterface the pointer of UNO interface. 194 */ 195 STDMETHODIMP CAccComponentBase::put_XInterface(long pXInterface) 196 { 197 198 CHECK_ENABLE_INF 199 200 ENTER_PROTECTED_BLOCK 201 202 CUNOXWrapper::put_XInterface(pXInterface); 203 //special query. 204 if(pUNOInterface == NULL) 205 return E_FAIL; 206 Reference<XAccessibleContext> pRContext = pUNOInterface->getAccessibleContext(); 207 if( !pRContext.is() ) 208 { 209 return E_FAIL; 210 } 211 Reference<XAccessibleComponent> pRXI(pRContext,UNO_QUERY); 212 if( !pRXI.is() ) 213 pRXComp = NULL; 214 else 215 pRXComp = pRXI.get(); 216 217 return S_OK; 218 219 LEAVE_PROTECTED_BLOCK 220 } 221