1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svx.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include <svx/AccessibleGraphicShape.hxx> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir #include <svx/ShapeTypeHandler.hxx> 35*cdf0e10cSrcweir #include <svx/SvxShapeTypes.hxx> 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir using namespace ::accessibility; 38*cdf0e10cSrcweir using namespace ::rtl; 39*cdf0e10cSrcweir using namespace ::com::sun::star; 40*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility; 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir //===== internal ============================================================ 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir AccessibleGraphicShape::AccessibleGraphicShape ( 45*cdf0e10cSrcweir const AccessibleShapeInfo& rShapeInfo, 46*cdf0e10cSrcweir const AccessibleShapeTreeInfo& rShapeTreeInfo) 47*cdf0e10cSrcweir : AccessibleShape (rShapeInfo, rShapeTreeInfo) 48*cdf0e10cSrcweir { 49*cdf0e10cSrcweir } 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir AccessibleGraphicShape::~AccessibleGraphicShape (void) 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir } 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir //===== XAccessibleImage ==================================================== 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleGraphicShape::getAccessibleImageDescription (void) 64*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir return AccessibleShape::getAccessibleDescription (); 67*cdf0e10cSrcweir } 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleGraphicShape::getAccessibleImageHeight (void) 73*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir return AccessibleShape::getSize().Height; 76*cdf0e10cSrcweir } 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleGraphicShape::getAccessibleImageWidth (void) 82*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir return AccessibleShape::getSize().Width; 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir //===== XInterface ========================================================== 91*cdf0e10cSrcweir 92*cdf0e10cSrcweir com::sun::star::uno::Any SAL_CALL 93*cdf0e10cSrcweir AccessibleGraphicShape::queryInterface (const com::sun::star::uno::Type & rType) 94*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir ::com::sun::star::uno::Any aReturn = AccessibleShape::queryInterface (rType); 97*cdf0e10cSrcweir if ( ! aReturn.hasValue()) 98*cdf0e10cSrcweir aReturn = ::cppu::queryInterface (rType, 99*cdf0e10cSrcweir static_cast<XAccessibleImage*>(this)); 100*cdf0e10cSrcweir return aReturn; 101*cdf0e10cSrcweir } 102*cdf0e10cSrcweir 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir 105*cdf0e10cSrcweir void SAL_CALL 106*cdf0e10cSrcweir AccessibleGraphicShape::acquire (void) 107*cdf0e10cSrcweir throw () 108*cdf0e10cSrcweir { 109*cdf0e10cSrcweir AccessibleShape::acquire (); 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir void SAL_CALL 115*cdf0e10cSrcweir AccessibleGraphicShape::release (void) 116*cdf0e10cSrcweir throw () 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir AccessibleShape::release (); 119*cdf0e10cSrcweir } 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir //===== XServiceInfo ======================================================== 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir ::rtl::OUString SAL_CALL 127*cdf0e10cSrcweir AccessibleGraphicShape::getImplementationName (void) 128*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir return ::rtl::OUString( 131*cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM("AccessibleGraphicShape")); 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL 138*cdf0e10cSrcweir AccessibleGraphicShape::getSupportedServiceNames (void) 139*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 140*cdf0e10cSrcweir { 141*cdf0e10cSrcweir ThrowIfDisposed (); 142*cdf0e10cSrcweir // Get list of supported service names from base class... 143*cdf0e10cSrcweir uno::Sequence<OUString> aServiceNames = 144*cdf0e10cSrcweir AccessibleShape::getSupportedServiceNames(); 145*cdf0e10cSrcweir sal_Int32 nCount (aServiceNames.getLength()); 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir // ...and add additional names. 148*cdf0e10cSrcweir aServiceNames.realloc (nCount + 1); 149*cdf0e10cSrcweir static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM( 150*cdf0e10cSrcweir "com.sun.star.drawing.AccessibleGraphicShape")); 151*cdf0e10cSrcweir aServiceNames[nCount] = sAdditionalServiceName; 152*cdf0e10cSrcweir 153*cdf0e10cSrcweir return aServiceNames; 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir //===== XTypeProvider =================================================== 160*cdf0e10cSrcweir 161*cdf0e10cSrcweir uno::Sequence<uno::Type> SAL_CALL 162*cdf0e10cSrcweir AccessibleGraphicShape::getTypes (void) 163*cdf0e10cSrcweir throw (uno::RuntimeException) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir // Get list of types from the context base implementation... 166*cdf0e10cSrcweir uno::Sequence<uno::Type> aTypeList (AccessibleShape::getTypes()); 167*cdf0e10cSrcweir // ...and add the additional type for the component. 168*cdf0e10cSrcweir long nTypeCount = aTypeList.getLength(); 169*cdf0e10cSrcweir aTypeList.realloc (nTypeCount + 1); 170*cdf0e10cSrcweir const uno::Type aImageType = 171*cdf0e10cSrcweir ::getCppuType((const uno::Reference<XAccessibleImage>*)0); 172*cdf0e10cSrcweir aTypeList[nTypeCount] = aImageType; 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir return aTypeList; 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir /// Create the base name of this object, i.e. the name without appended number. 181*cdf0e10cSrcweir ::rtl::OUString 182*cdf0e10cSrcweir AccessibleGraphicShape::CreateAccessibleBaseName (void) 183*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir ::rtl::OUString sName; 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape); 188*cdf0e10cSrcweir switch (nShapeType) 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir case DRAWING_GRAPHIC_OBJECT: 191*cdf0e10cSrcweir sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("GraphicObjectShape")); 192*cdf0e10cSrcweir break; 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir default: 195*cdf0e10cSrcweir sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("UnknownAccessibleGraphicShape")); 196*cdf0e10cSrcweir uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY); 197*cdf0e10cSrcweir if (xDescriptor.is()) 198*cdf0e10cSrcweir sName += ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM(": ")) 199*cdf0e10cSrcweir + xDescriptor->getShapeType(); 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir return sName; 203*cdf0e10cSrcweir } 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir ::rtl::OUString 208*cdf0e10cSrcweir AccessibleGraphicShape::CreateAccessibleDescription (void) 209*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException) 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir return CreateAccessibleName (); 212*cdf0e10cSrcweir } 213