1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_chart2.hxx" 26 27 #include "AccessibleChartShape.hxx" 28 #include "ObjectHierarchy.hxx" 29 #include "ObjectIdentifier.hxx" 30 31 #include <toolkit/helper/vclunohelper.hxx> 32 #include <svx/ShapeTypeHandler.hxx> 33 #include <svx/AccessibleShape.hxx> 34 #include <svx/AccessibleShapeInfo.hxx> 35 36 using namespace ::com::sun::star; 37 using namespace ::com::sun::star::accessibility; 38 39 using ::com::sun::star::uno::Reference; 40 using ::com::sun::star::uno::RuntimeException; 41 42 43 namespace chart 44 { 45 46 AccessibleChartShape::AccessibleChartShape( 47 const AccessibleElementInfo& rAccInfo, 48 bool bMayHaveChildren, bool bAlwaysTransparent ) 49 :impl::AccessibleChartShape_Base( rAccInfo, bMayHaveChildren, bAlwaysTransparent ) 50 ,m_pAccShape( NULL ) 51 { 52 if ( rAccInfo.m_aOID.isAdditionalShape() ) 53 { 54 Reference< drawing::XShape > xShape( rAccInfo.m_aOID.getAdditionalShape() ); 55 Reference< XAccessible > xParent; 56 if ( rAccInfo.m_pParent ) 57 { 58 xParent.set( rAccInfo.m_pParent ); 59 } 60 sal_Int32 nIndex = -1; 61 if ( rAccInfo.m_spObjectHierarchy ) 62 { 63 nIndex = rAccInfo.m_spObjectHierarchy->getIndexInParent( rAccInfo.m_aOID ); 64 } 65 ::accessibility::AccessibleShapeInfo aShapeInfo( xShape, xParent, nIndex ); 66 67 m_aShapeTreeInfo.SetSdrView( rAccInfo.m_pSdrView ); 68 m_aShapeTreeInfo.SetController( NULL ); 69 m_aShapeTreeInfo.SetWindow( VCLUnoHelper::GetWindow( rAccInfo.m_xWindow ) ); 70 m_aShapeTreeInfo.SetViewForwarder( rAccInfo.m_pViewForwarder ); 71 72 ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance(); 73 m_pAccShape = rShapeHandler.CreateAccessibleObject( aShapeInfo, m_aShapeTreeInfo ); 74 if ( m_pAccShape ) 75 { 76 m_pAccShape->acquire(); 77 m_pAccShape->Init(); 78 } 79 } 80 } 81 82 AccessibleChartShape::~AccessibleChartShape() 83 { 84 OSL_ASSERT( CheckDisposeState( false /* don't throw exceptions */ ) ); 85 86 if ( m_pAccShape ) 87 { 88 m_pAccShape->dispose(); 89 m_pAccShape->release(); 90 } 91 } 92 93 // ________ XServiceInfo ________ 94 ::rtl::OUString AccessibleChartShape::getImplementationName() 95 throw (RuntimeException) 96 { 97 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AccessibleChartShape" ) ); 98 } 99 100 // ________ XAccessibleContext ________ 101 sal_Int32 AccessibleChartShape::getAccessibleChildCount() 102 throw (RuntimeException) 103 { 104 sal_Int32 nCount(0); 105 if ( m_pAccShape ) 106 { 107 nCount = m_pAccShape->getAccessibleChildCount(); 108 } 109 return nCount; 110 } 111 112 Reference< XAccessible > AccessibleChartShape::getAccessibleChild( sal_Int32 i ) 113 throw (lang::IndexOutOfBoundsException, RuntimeException) 114 { 115 Reference< XAccessible > xChild; 116 if ( m_pAccShape ) 117 { 118 xChild = m_pAccShape->getAccessibleChild( i ); 119 } 120 return xChild; 121 } 122 123 sal_Int16 AccessibleChartShape::getAccessibleRole() 124 throw (RuntimeException) 125 { 126 sal_Int16 nRole(0); 127 if ( m_pAccShape ) 128 { 129 nRole = m_pAccShape->getAccessibleRole(); 130 } 131 return nRole; 132 } 133 134 ::rtl::OUString AccessibleChartShape::getAccessibleDescription() 135 throw (::com::sun::star::uno::RuntimeException) 136 { 137 ::rtl::OUString aDescription; 138 if ( m_pAccShape ) 139 { 140 aDescription = m_pAccShape->getAccessibleDescription(); 141 } 142 return aDescription; 143 } 144 145 ::rtl::OUString AccessibleChartShape::getAccessibleName() 146 throw (::com::sun::star::uno::RuntimeException) 147 { 148 ::rtl::OUString aName; 149 if ( m_pAccShape ) 150 { 151 aName = m_pAccShape->getAccessibleName(); 152 } 153 return aName; 154 } 155 156 // ________ XAccessibleComponent ________ 157 sal_Bool AccessibleChartShape::containsPoint( const awt::Point& aPoint ) 158 throw (uno::RuntimeException) 159 { 160 sal_Bool bReturn = sal_False; 161 if ( m_pAccShape ) 162 { 163 bReturn = m_pAccShape->containsPoint( aPoint ); 164 } 165 return bReturn; 166 } 167 168 Reference< XAccessible > AccessibleChartShape::getAccessibleAtPoint( const awt::Point& aPoint ) 169 throw (uno::RuntimeException) 170 { 171 Reference< XAccessible > xResult; 172 if ( m_pAccShape ) 173 { 174 xResult.set( m_pAccShape->getAccessibleAtPoint( aPoint ) ); 175 } 176 return xResult; 177 } 178 179 awt::Rectangle AccessibleChartShape::getBounds() 180 throw (uno::RuntimeException) 181 { 182 awt::Rectangle aBounds; 183 if ( m_pAccShape ) 184 { 185 aBounds = m_pAccShape->getBounds(); 186 } 187 return aBounds; 188 } 189 190 awt::Point AccessibleChartShape::getLocation() 191 throw (uno::RuntimeException) 192 { 193 awt::Point aLocation; 194 if ( m_pAccShape ) 195 { 196 aLocation = m_pAccShape->getLocation(); 197 } 198 return aLocation; 199 } 200 201 awt::Point AccessibleChartShape::getLocationOnScreen() 202 throw (uno::RuntimeException) 203 { 204 awt::Point aLocation; 205 if ( m_pAccShape ) 206 { 207 aLocation = m_pAccShape->getLocationOnScreen(); 208 } 209 return aLocation; 210 } 211 212 awt::Size AccessibleChartShape::getSize() 213 throw (uno::RuntimeException) 214 { 215 awt::Size aSize; 216 if ( m_pAccShape ) 217 { 218 aSize = m_pAccShape->getSize(); 219 } 220 return aSize; 221 } 222 223 void AccessibleChartShape::grabFocus() 224 throw (uno::RuntimeException) 225 { 226 return AccessibleBase::grabFocus(); 227 } 228 229 sal_Int32 AccessibleChartShape::getForeground() 230 throw (uno::RuntimeException) 231 { 232 sal_Int32 nColor(0); 233 if ( m_pAccShape ) 234 { 235 nColor = m_pAccShape->getForeground(); 236 } 237 return nColor; 238 } 239 240 sal_Int32 AccessibleChartShape::getBackground() 241 throw (uno::RuntimeException) 242 { 243 sal_Int32 nColor(0); 244 if ( m_pAccShape ) 245 { 246 nColor = m_pAccShape->getBackground(); 247 } 248 return nColor; 249 } 250 251 // ________ XAccessibleExtendedComponent ________ 252 Reference< awt::XFont > AccessibleChartShape::getFont() 253 throw (uno::RuntimeException) 254 { 255 Reference< awt::XFont > xFont; 256 if ( m_pAccShape ) 257 { 258 xFont.set( m_pAccShape->getFont() ); 259 } 260 return xFont; 261 } 262 263 ::rtl::OUString AccessibleChartShape::getTitledBorderText() 264 throw (uno::RuntimeException) 265 { 266 ::rtl::OUString aText; 267 if ( m_pAccShape ) 268 { 269 aText = m_pAccShape->getTitledBorderText(); 270 } 271 return aText; 272 } 273 274 ::rtl::OUString AccessibleChartShape::getToolTipText() 275 throw (::com::sun::star::uno::RuntimeException) 276 { 277 ::rtl::OUString aText; 278 if ( m_pAccShape ) 279 { 280 aText = m_pAccShape->getToolTipText(); 281 } 282 return aText; 283 } 284 285 } // namespace chart 286