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