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_svx.hxx" 26 27 28 #include <svx/AccessibleGraphicShape.hxx> 29 30 #include <svx/ShapeTypeHandler.hxx> 31 #include <svx/SvxShapeTypes.hxx> 32 #include <svx/svdobj.hxx> 33 #include <svx/svdmodel.hxx> 34 35 using namespace ::accessibility; 36 using namespace ::rtl; 37 using namespace ::com::sun::star; 38 using namespace ::com::sun::star::accessibility; 39 40 //===== internal ============================================================ 41 42 AccessibleGraphicShape::AccessibleGraphicShape ( 43 const AccessibleShapeInfo& rShapeInfo, 44 const AccessibleShapeTreeInfo& rShapeTreeInfo) 45 : AccessibleShape (rShapeInfo, rShapeTreeInfo) 46 { 47 } 48 49 50 51 52 AccessibleGraphicShape::~AccessibleGraphicShape (void) 53 { 54 } 55 56 57 58 59 //===== XAccessibleImage ==================================================== 60 61 ::rtl::OUString SAL_CALL AccessibleGraphicShape::getAccessibleImageDescription (void) 62 throw (::com::sun::star::uno::RuntimeException) 63 { 64 //IAccessibility2 Implementation 2009----- 65 if(m_pShape) 66 return m_pShape->GetTitle(); 67 //-----IAccessibility2 Implementation 2009 68 return AccessibleShape::getAccessibleDescription (); 69 } 70 71 72 73 74 sal_Int32 SAL_CALL AccessibleGraphicShape::getAccessibleImageHeight (void) 75 throw (::com::sun::star::uno::RuntimeException) 76 { 77 return AccessibleShape::getSize().Height; 78 } 79 80 81 82 83 sal_Int32 SAL_CALL AccessibleGraphicShape::getAccessibleImageWidth (void) 84 throw (::com::sun::star::uno::RuntimeException) 85 { 86 return AccessibleShape::getSize().Width; 87 } 88 89 90 91 92 //===== XInterface ========================================================== 93 94 com::sun::star::uno::Any SAL_CALL 95 AccessibleGraphicShape::queryInterface (const com::sun::star::uno::Type & rType) 96 throw (::com::sun::star::uno::RuntimeException) 97 { 98 ::com::sun::star::uno::Any aReturn = AccessibleShape::queryInterface (rType); 99 if ( ! aReturn.hasValue()) 100 aReturn = ::cppu::queryInterface (rType, 101 static_cast<XAccessibleImage*>(this)); 102 return aReturn; 103 } 104 105 106 107 void SAL_CALL 108 AccessibleGraphicShape::acquire (void) 109 throw () 110 { 111 AccessibleShape::acquire (); 112 } 113 114 115 116 void SAL_CALL 117 AccessibleGraphicShape::release (void) 118 throw () 119 { 120 AccessibleShape::release (); 121 } 122 123 124 125 126 //===== XServiceInfo ======================================================== 127 128 ::rtl::OUString SAL_CALL 129 AccessibleGraphicShape::getImplementationName (void) 130 throw (::com::sun::star::uno::RuntimeException) 131 { 132 return ::rtl::OUString( 133 RTL_CONSTASCII_USTRINGPARAM("AccessibleGraphicShape")); 134 } 135 136 137 138 139 ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL 140 AccessibleGraphicShape::getSupportedServiceNames (void) 141 throw (::com::sun::star::uno::RuntimeException) 142 { 143 ThrowIfDisposed (); 144 // Get list of supported service names from base class... 145 uno::Sequence<OUString> aServiceNames = 146 AccessibleShape::getSupportedServiceNames(); 147 sal_Int32 nCount (aServiceNames.getLength()); 148 149 // ...and add additional names. 150 aServiceNames.realloc (nCount + 1); 151 static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM( 152 "com.sun.star.drawing.AccessibleGraphicShape")); 153 aServiceNames[nCount] = sAdditionalServiceName; 154 155 return aServiceNames; 156 } 157 158 159 160 161 //===== XTypeProvider =================================================== 162 163 uno::Sequence<uno::Type> SAL_CALL 164 AccessibleGraphicShape::getTypes (void) 165 throw (uno::RuntimeException) 166 { 167 // Get list of types from the context base implementation... 168 uno::Sequence<uno::Type> aTypeList (AccessibleShape::getTypes()); 169 // ...and add the additional type for the component. 170 long nTypeCount = aTypeList.getLength(); 171 aTypeList.realloc (nTypeCount + 1); 172 const uno::Type aImageType = 173 ::getCppuType((const uno::Reference<XAccessibleImage>*)0); 174 aTypeList[nTypeCount] = aImageType; 175 176 return aTypeList; 177 } 178 179 180 181 182 /// Create the base name of this object, i.e. the name without appended number. 183 ::rtl::OUString 184 AccessibleGraphicShape::CreateAccessibleBaseName (void) 185 throw (::com::sun::star::uno::RuntimeException) 186 { 187 ::rtl::OUString sName; 188 189 ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape); 190 switch (nShapeType) 191 { 192 case DRAWING_GRAPHIC_OBJECT: 193 sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("GraphicObjectShape")); 194 break; 195 196 default: 197 sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("UnknownAccessibleGraphicShape")); 198 uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY); 199 if (xDescriptor.is()) 200 sName += ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM(": ")) 201 + xDescriptor->getShapeType(); 202 } 203 204 return sName; 205 } 206 207 208 209 ::rtl::OUString 210 AccessibleGraphicShape::CreateAccessibleDescription (void) 211 throw (::com::sun::star::uno::RuntimeException) 212 { 213 //IAccessibility2 Implementation 2009----- 214 //Solution: Don't use the same information for accessible name and accessible description. 215 //return CreateAccessibleName (); 216 ::rtl::OUString sDesc; 217 if(m_pShape) 218 sDesc = m_pShape->GetTitle(); 219 if(sDesc.getLength() > 0) 220 return sDesc; 221 return CreateAccessibleBaseName(); 222 //-----IAccessibility2 Implementation 2009 223 } 224 //IAccessibility2 Implementation 2009----- 225 // Return this object's role. 226 sal_Int16 SAL_CALL AccessibleGraphicShape::getAccessibleRole (void) 227 throw (::com::sun::star::uno::RuntimeException) 228 { 229 sal_Int16 nAccessibleRole = AccessibleRole::SHAPE; 230 if( m_pShape->GetModel()->GetImageMapForObject(m_pShape) != NULL ) 231 return AccessibleRole::IMAGE_MAP; 232 else 233 //return AccessibleRole::SHAPE; 234 return AccessibleShape::getAccessibleRole(); 235 return nAccessibleRole; 236 } 237 //-----IAccessibility2 Implementation 2009 238 239 240