1f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f6e50924SAndrew Rist * distributed with this work for additional information 6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10f6e50924SAndrew Rist * 11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12f6e50924SAndrew Rist * 13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f6e50924SAndrew Rist * software distributed under the License is distributed on an 15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17f6e50924SAndrew Rist * specific language governing permissions and limitations 18f6e50924SAndrew Rist * under the License. 19f6e50924SAndrew Rist * 20f6e50924SAndrew Rist *************************************************************/ 21f6e50924SAndrew Rist 22f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <svx/AccessibleGraphicShape.hxx> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <svx/ShapeTypeHandler.hxx> 31cdf0e10cSrcweir #include <svx/SvxShapeTypes.hxx> 32*9b8096d0SSteve Yin #include <svx/svdobj.hxx> 33*9b8096d0SSteve Yin #include <svx/svdmodel.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir using namespace ::accessibility; 36cdf0e10cSrcweir using namespace ::rtl; 37cdf0e10cSrcweir using namespace ::com::sun::star; 38cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 39cdf0e10cSrcweir 40cdf0e10cSrcweir //===== internal ============================================================ 41cdf0e10cSrcweir 42cdf0e10cSrcweir AccessibleGraphicShape::AccessibleGraphicShape ( 43cdf0e10cSrcweir const AccessibleShapeInfo& rShapeInfo, 44cdf0e10cSrcweir const AccessibleShapeTreeInfo& rShapeTreeInfo) 45cdf0e10cSrcweir : AccessibleShape (rShapeInfo, rShapeTreeInfo) 46cdf0e10cSrcweir { 47cdf0e10cSrcweir } 48cdf0e10cSrcweir 49cdf0e10cSrcweir 50cdf0e10cSrcweir 51cdf0e10cSrcweir 52cdf0e10cSrcweir AccessibleGraphicShape::~AccessibleGraphicShape (void) 53cdf0e10cSrcweir { 54cdf0e10cSrcweir } 55cdf0e10cSrcweir 56cdf0e10cSrcweir 57cdf0e10cSrcweir 58cdf0e10cSrcweir 59cdf0e10cSrcweir //===== XAccessibleImage ==================================================== 60cdf0e10cSrcweir 61cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleGraphicShape::getAccessibleImageDescription (void) 62cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 63cdf0e10cSrcweir { 64*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 65*9b8096d0SSteve Yin if(m_pShape) 66*9b8096d0SSteve Yin return m_pShape->GetTitle(); 67*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 68cdf0e10cSrcweir return AccessibleShape::getAccessibleDescription (); 69cdf0e10cSrcweir } 70cdf0e10cSrcweir 71cdf0e10cSrcweir 72cdf0e10cSrcweir 73cdf0e10cSrcweir 74cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleGraphicShape::getAccessibleImageHeight (void) 75cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 76cdf0e10cSrcweir { 77cdf0e10cSrcweir return AccessibleShape::getSize().Height; 78cdf0e10cSrcweir } 79cdf0e10cSrcweir 80cdf0e10cSrcweir 81cdf0e10cSrcweir 82cdf0e10cSrcweir 83cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleGraphicShape::getAccessibleImageWidth (void) 84cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 85cdf0e10cSrcweir { 86cdf0e10cSrcweir return AccessibleShape::getSize().Width; 87cdf0e10cSrcweir } 88cdf0e10cSrcweir 89cdf0e10cSrcweir 90cdf0e10cSrcweir 91cdf0e10cSrcweir 92cdf0e10cSrcweir //===== XInterface ========================================================== 93cdf0e10cSrcweir 94cdf0e10cSrcweir com::sun::star::uno::Any SAL_CALL 95cdf0e10cSrcweir AccessibleGraphicShape::queryInterface (const com::sun::star::uno::Type & rType) 96cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 97cdf0e10cSrcweir { 98cdf0e10cSrcweir ::com::sun::star::uno::Any aReturn = AccessibleShape::queryInterface (rType); 99cdf0e10cSrcweir if ( ! aReturn.hasValue()) 100cdf0e10cSrcweir aReturn = ::cppu::queryInterface (rType, 101cdf0e10cSrcweir static_cast<XAccessibleImage*>(this)); 102cdf0e10cSrcweir return aReturn; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir 106cdf0e10cSrcweir 107cdf0e10cSrcweir void SAL_CALL 108cdf0e10cSrcweir AccessibleGraphicShape::acquire (void) 109cdf0e10cSrcweir throw () 110cdf0e10cSrcweir { 111cdf0e10cSrcweir AccessibleShape::acquire (); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir 115cdf0e10cSrcweir 116cdf0e10cSrcweir void SAL_CALL 117cdf0e10cSrcweir AccessibleGraphicShape::release (void) 118cdf0e10cSrcweir throw () 119cdf0e10cSrcweir { 120cdf0e10cSrcweir AccessibleShape::release (); 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir 124cdf0e10cSrcweir 125cdf0e10cSrcweir 126cdf0e10cSrcweir //===== XServiceInfo ======================================================== 127cdf0e10cSrcweir 128cdf0e10cSrcweir ::rtl::OUString SAL_CALL 129cdf0e10cSrcweir AccessibleGraphicShape::getImplementationName (void) 130cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 131cdf0e10cSrcweir { 132cdf0e10cSrcweir return ::rtl::OUString( 133cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("AccessibleGraphicShape")); 134cdf0e10cSrcweir } 135cdf0e10cSrcweir 136cdf0e10cSrcweir 137cdf0e10cSrcweir 138cdf0e10cSrcweir 139cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL 140cdf0e10cSrcweir AccessibleGraphicShape::getSupportedServiceNames (void) 141cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir ThrowIfDisposed (); 144cdf0e10cSrcweir // Get list of supported service names from base class... 145cdf0e10cSrcweir uno::Sequence<OUString> aServiceNames = 146cdf0e10cSrcweir AccessibleShape::getSupportedServiceNames(); 147cdf0e10cSrcweir sal_Int32 nCount (aServiceNames.getLength()); 148cdf0e10cSrcweir 149cdf0e10cSrcweir // ...and add additional names. 150cdf0e10cSrcweir aServiceNames.realloc (nCount + 1); 151cdf0e10cSrcweir static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM( 152cdf0e10cSrcweir "com.sun.star.drawing.AccessibleGraphicShape")); 153cdf0e10cSrcweir aServiceNames[nCount] = sAdditionalServiceName; 154cdf0e10cSrcweir 155cdf0e10cSrcweir return aServiceNames; 156cdf0e10cSrcweir } 157cdf0e10cSrcweir 158cdf0e10cSrcweir 159cdf0e10cSrcweir 160cdf0e10cSrcweir 161cdf0e10cSrcweir //===== XTypeProvider =================================================== 162cdf0e10cSrcweir 163cdf0e10cSrcweir uno::Sequence<uno::Type> SAL_CALL 164cdf0e10cSrcweir AccessibleGraphicShape::getTypes (void) 165cdf0e10cSrcweir throw (uno::RuntimeException) 166cdf0e10cSrcweir { 167cdf0e10cSrcweir // Get list of types from the context base implementation... 168cdf0e10cSrcweir uno::Sequence<uno::Type> aTypeList (AccessibleShape::getTypes()); 169cdf0e10cSrcweir // ...and add the additional type for the component. 170cdf0e10cSrcweir long nTypeCount = aTypeList.getLength(); 171cdf0e10cSrcweir aTypeList.realloc (nTypeCount + 1); 172cdf0e10cSrcweir const uno::Type aImageType = 173cdf0e10cSrcweir ::getCppuType((const uno::Reference<XAccessibleImage>*)0); 174cdf0e10cSrcweir aTypeList[nTypeCount] = aImageType; 175cdf0e10cSrcweir 176cdf0e10cSrcweir return aTypeList; 177cdf0e10cSrcweir } 178cdf0e10cSrcweir 179cdf0e10cSrcweir 180cdf0e10cSrcweir 181cdf0e10cSrcweir 182cdf0e10cSrcweir /// Create the base name of this object, i.e. the name without appended number. 183cdf0e10cSrcweir ::rtl::OUString 184cdf0e10cSrcweir AccessibleGraphicShape::CreateAccessibleBaseName (void) 185cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 186cdf0e10cSrcweir { 187cdf0e10cSrcweir ::rtl::OUString sName; 188cdf0e10cSrcweir 189cdf0e10cSrcweir ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape); 190cdf0e10cSrcweir switch (nShapeType) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir case DRAWING_GRAPHIC_OBJECT: 193cdf0e10cSrcweir sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("GraphicObjectShape")); 194cdf0e10cSrcweir break; 195cdf0e10cSrcweir 196cdf0e10cSrcweir default: 197cdf0e10cSrcweir sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("UnknownAccessibleGraphicShape")); 198cdf0e10cSrcweir uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY); 199cdf0e10cSrcweir if (xDescriptor.is()) 200cdf0e10cSrcweir sName += ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM(": ")) 201cdf0e10cSrcweir + xDescriptor->getShapeType(); 202cdf0e10cSrcweir } 203cdf0e10cSrcweir 204cdf0e10cSrcweir return sName; 205cdf0e10cSrcweir } 206cdf0e10cSrcweir 207cdf0e10cSrcweir 208cdf0e10cSrcweir 209cdf0e10cSrcweir ::rtl::OUString 210cdf0e10cSrcweir AccessibleGraphicShape::CreateAccessibleDescription (void) 211cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 212cdf0e10cSrcweir { 213*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 214*9b8096d0SSteve Yin //Solution: Don't use the same information for accessible name and accessible description. 215*9b8096d0SSteve Yin //return CreateAccessibleName (); 216*9b8096d0SSteve Yin ::rtl::OUString sDesc; 217*9b8096d0SSteve Yin if(m_pShape) 218*9b8096d0SSteve Yin sDesc = m_pShape->GetTitle(); 219*9b8096d0SSteve Yin if(sDesc.getLength() > 0) 220*9b8096d0SSteve Yin return sDesc; 221*9b8096d0SSteve Yin return CreateAccessibleBaseName(); 222*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 223cdf0e10cSrcweir } 224*9b8096d0SSteve Yin //IAccessibility2 Implementation 2009----- 225*9b8096d0SSteve Yin // Return this object's role. 226*9b8096d0SSteve Yin sal_Int16 SAL_CALL AccessibleGraphicShape::getAccessibleRole (void) 227*9b8096d0SSteve Yin throw (::com::sun::star::uno::RuntimeException) 228*9b8096d0SSteve Yin { 229*9b8096d0SSteve Yin sal_Int16 nAccessibleRole = AccessibleRole::SHAPE; 230*9b8096d0SSteve Yin if( m_pShape->GetModel()->GetImageMapForObject(m_pShape) != NULL ) 231*9b8096d0SSteve Yin return AccessibleRole::IMAGE_MAP; 232*9b8096d0SSteve Yin else 233*9b8096d0SSteve Yin //return AccessibleRole::SHAPE; 234*9b8096d0SSteve Yin return AccessibleShape::getAccessibleRole(); 235*9b8096d0SSteve Yin return nAccessibleRole; 236*9b8096d0SSteve Yin } 237*9b8096d0SSteve Yin //-----IAccessibility2 Implementation 2009 238*9b8096d0SSteve Yin 239*9b8096d0SSteve Yin 240