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/AccessibleOLEShape.hxx> 29 30 #include <svx/ShapeTypeHandler.hxx> 31 #include <svx/SvxShapeTypes.hxx> 32 #include <svx/svdoole2.hxx> 33 using namespace accessibility; 34 using namespace ::com::sun::star; 35 using namespace ::com::sun::star::uno; 36 using namespace ::com::sun::star::accessibility; 37 38 //===== internal ============================================================ 39 40 AccessibleOLEShape::AccessibleOLEShape ( 41 const AccessibleShapeInfo& rShapeInfo, 42 const AccessibleShapeTreeInfo& rShapeTreeInfo) 43 : AccessibleShape (rShapeInfo, rShapeTreeInfo) 44 { 45 } 46 47 48 49 50 AccessibleOLEShape::~AccessibleOLEShape (void) 51 { 52 } 53 54 55 56 57 //===== XAccessibleAction =================================================== 58 59 sal_Int32 SAL_CALL AccessibleOLEShape::getAccessibleActionCount (void) 60 throw (::com::sun::star::uno::RuntimeException) 61 { 62 return 0; 63 } 64 65 66 67 68 sal_Bool SAL_CALL AccessibleOLEShape::doAccessibleAction (sal_Int32 /*nIndex*/) 69 throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 70 { 71 throw lang::IndexOutOfBoundsException(); 72 } 73 74 75 76 77 ::rtl::OUString SAL_CALL AccessibleOLEShape::getAccessibleActionDescription (sal_Int32 /*nIndex*/) 78 throw (::com::sun::star::lang::IndexOutOfBoundsException, 79 ::com::sun::star::uno::RuntimeException) 80 { 81 throw lang::IndexOutOfBoundsException(); 82 } 83 84 85 86 87 Reference<XAccessibleKeyBinding> SAL_CALL AccessibleOLEShape::getAccessibleActionKeyBinding (sal_Int32 /*nIndex*/) 88 throw (::com::sun::star::lang::IndexOutOfBoundsException, 89 ::com::sun::star::uno::RuntimeException) 90 { 91 throw lang::IndexOutOfBoundsException(); 92 } 93 94 95 96 97 //===== XInterface ========================================================== 98 99 com::sun::star::uno::Any SAL_CALL 100 AccessibleOLEShape::queryInterface (const com::sun::star::uno::Type & rType) 101 throw (::com::sun::star::uno::RuntimeException) 102 { 103 ::com::sun::star::uno::Any aReturn = AccessibleShape::queryInterface (rType); 104 if ( ! aReturn.hasValue()) 105 aReturn = ::cppu::queryInterface (rType, 106 static_cast<XAccessibleAction*>(this)); 107 return aReturn; 108 } 109 110 111 112 void SAL_CALL 113 AccessibleOLEShape::acquire (void) 114 throw () 115 { 116 AccessibleShape::acquire (); 117 } 118 119 120 121 void SAL_CALL 122 AccessibleOLEShape::release (void) 123 throw () 124 { 125 AccessibleShape::release (); 126 } 127 128 129 130 131 //===== XServiceInfo ======================================================== 132 133 ::rtl::OUString SAL_CALL 134 AccessibleOLEShape::getImplementationName (void) 135 throw (::com::sun::star::uno::RuntimeException) 136 { 137 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleOLEShape")); 138 } 139 140 141 142 143 ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL 144 AccessibleOLEShape::getSupportedServiceNames (void) 145 throw (::com::sun::star::uno::RuntimeException) 146 { 147 ThrowIfDisposed(); 148 // Get list of supported service names from base class... 149 uno::Sequence< ::rtl::OUString > aServiceNames = 150 AccessibleShape::getSupportedServiceNames(); 151 sal_Int32 nCount (aServiceNames.getLength()); 152 153 // ...and add additional names. 154 aServiceNames.realloc (nCount + 1); 155 static const ::rtl::OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM( 156 "com.sun.star.drawing.AccessibleOLEShape")); 157 aServiceNames[nCount] = sAdditionalServiceName; 158 159 return aServiceNames; 160 } 161 162 163 164 165 //===== XTypeProvider =================================================== 166 167 uno::Sequence<uno::Type> SAL_CALL 168 AccessibleOLEShape::getTypes (void) 169 throw (uno::RuntimeException) 170 { 171 // Get list of types from the context base implementation... 172 uno::Sequence<uno::Type> aTypeList (AccessibleShape::getTypes()); 173 // ...and add the additional type for the component. 174 long nTypeCount = aTypeList.getLength(); 175 aTypeList.realloc (nTypeCount + 1); 176 const uno::Type aActionType = 177 ::getCppuType((const uno::Reference<XAccessibleAction>*)0); 178 aTypeList[nTypeCount] = aActionType; 179 180 return aTypeList; 181 } 182 //===== XAccessibleExtendedAttributes ======================================================== 183 uno::Any SAL_CALL AccessibleOLEShape::getExtendedAttributes() 184 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException) 185 { 186 uno::Any strRet; 187 ::rtl::OUString style; 188 if( m_pShape ) 189 { 190 //style = ::rtl::OUString::createFromAscii("style="); 191 style = ::rtl::OUString::createFromAscii("style:"); 192 style += ((SdrOle2Obj*)m_pShape)->GetStyleString(); 193 } 194 style += ::rtl::OUString::createFromAscii(";"); 195 strRet <<= style; 196 return strRet; 197 } 198 199 200 /// Set this object's name if is different to the current name. 201 ::rtl::OUString 202 AccessibleOLEShape::CreateAccessibleBaseName (void) 203 throw (::com::sun::star::uno::RuntimeException) 204 { 205 ::rtl::OUString sName; 206 207 ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape); 208 switch (nShapeType) 209 { 210 case DRAWING_APPLET: 211 sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("AppletOLEShape")); 212 break; 213 case DRAWING_FRAME: 214 sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("FrameOLEShape")); 215 break; 216 case DRAWING_OLE: 217 sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("OLEShape")); 218 break; 219 case DRAWING_PLUGIN: 220 sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("PluginOLEShape")); 221 break; 222 223 default: 224 sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("UnknownAccessibleOLEShape")); 225 uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY); 226 if (xDescriptor.is()) 227 sName += ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM(": ")) 228 + xDescriptor->getShapeType(); 229 } 230 231 return sName; 232 } 233 234 235 236 ::rtl::OUString 237 AccessibleOLEShape::CreateAccessibleDescription (void) 238 throw (::com::sun::star::uno::RuntimeException) 239 { 240 return CreateAccessibleName (); 241 } 242 243