Update ooo320-m1
[ooovba.git] / svx / source / accessibility / AccessibleGraphicShape.cxx
blob6b5f1ed8bcf4783bf0d61ed96665ffb19f588e4e
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleGraphicShape.cxx,v $
10 * $Revision: 1.15 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
35 #include <svx/AccessibleGraphicShape.hxx>
37 #include <svx/ShapeTypeHandler.hxx>
38 #include <svx/SvxShapeTypes.hxx>
40 using namespace ::accessibility;
41 using namespace ::rtl;
42 using namespace ::com::sun::star;
43 using namespace ::com::sun::star::accessibility;
45 //===== internal ============================================================
47 AccessibleGraphicShape::AccessibleGraphicShape (
48 const AccessibleShapeInfo& rShapeInfo,
49 const AccessibleShapeTreeInfo& rShapeTreeInfo)
50 : AccessibleShape (rShapeInfo, rShapeTreeInfo)
57 AccessibleGraphicShape::~AccessibleGraphicShape (void)
64 //===== XAccessibleImage ====================================================
66 ::rtl::OUString SAL_CALL AccessibleGraphicShape::getAccessibleImageDescription (void)
67 throw (::com::sun::star::uno::RuntimeException)
69 return AccessibleShape::getAccessibleDescription ();
75 sal_Int32 SAL_CALL AccessibleGraphicShape::getAccessibleImageHeight (void)
76 throw (::com::sun::star::uno::RuntimeException)
78 return AccessibleShape::getSize().Height;
84 sal_Int32 SAL_CALL AccessibleGraphicShape::getAccessibleImageWidth (void)
85 throw (::com::sun::star::uno::RuntimeException)
87 return AccessibleShape::getSize().Width;
93 //===== XInterface ==========================================================
95 com::sun::star::uno::Any SAL_CALL
96 AccessibleGraphicShape::queryInterface (const com::sun::star::uno::Type & rType)
97 throw (::com::sun::star::uno::RuntimeException)
99 ::com::sun::star::uno::Any aReturn = AccessibleShape::queryInterface (rType);
100 if ( ! aReturn.hasValue())
101 aReturn = ::cppu::queryInterface (rType,
102 static_cast<XAccessibleImage*>(this));
103 return aReturn;
108 void SAL_CALL
109 AccessibleGraphicShape::acquire (void)
110 throw ()
112 AccessibleShape::acquire ();
117 void SAL_CALL
118 AccessibleGraphicShape::release (void)
119 throw ()
121 AccessibleShape::release ();
127 //===== XServiceInfo ========================================================
129 ::rtl::OUString SAL_CALL
130 AccessibleGraphicShape::getImplementationName (void)
131 throw (::com::sun::star::uno::RuntimeException)
133 return ::rtl::OUString(
134 RTL_CONSTASCII_USTRINGPARAM("AccessibleGraphicShape"));
140 ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
141 AccessibleGraphicShape::getSupportedServiceNames (void)
142 throw (::com::sun::star::uno::RuntimeException)
144 ThrowIfDisposed ();
145 // Get list of supported service names from base class...
146 uno::Sequence<OUString> aServiceNames =
147 AccessibleShape::getSupportedServiceNames();
148 sal_Int32 nCount (aServiceNames.getLength());
150 // ...and add additional names.
151 aServiceNames.realloc (nCount + 1);
152 static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM(
153 "com.sun.star.drawing.AccessibleGraphicShape"));
154 aServiceNames[nCount] = sAdditionalServiceName;
156 return aServiceNames;
162 //===== XTypeProvider ===================================================
164 uno::Sequence<uno::Type> SAL_CALL
165 AccessibleGraphicShape::getTypes (void)
166 throw (uno::RuntimeException)
168 // Get list of types from the context base implementation...
169 uno::Sequence<uno::Type> aTypeList (AccessibleShape::getTypes());
170 // ...and add the additional type for the component.
171 long nTypeCount = aTypeList.getLength();
172 aTypeList.realloc (nTypeCount + 1);
173 const uno::Type aImageType =
174 ::getCppuType((const uno::Reference<XAccessibleImage>*)0);
175 aTypeList[nTypeCount] = aImageType;
177 return aTypeList;
183 /// Create the base name of this object, i.e. the name without appended number.
184 ::rtl::OUString
185 AccessibleGraphicShape::CreateAccessibleBaseName (void)
186 throw (::com::sun::star::uno::RuntimeException)
188 ::rtl::OUString sName;
190 ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape);
191 switch (nShapeType)
193 case DRAWING_GRAPHIC_OBJECT:
194 sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("GraphicObjectShape"));
195 break;
197 default:
198 sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("UnknownAccessibleGraphicShape"));
199 uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY);
200 if (xDescriptor.is())
201 sName += ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM(": "))
202 + xDescriptor->getShapeType();
205 return sName;
210 ::rtl::OUString
211 AccessibleGraphicShape::CreateAccessibleDescription (void)
212 throw (::com::sun::star::uno::RuntimeException)
214 return CreateAccessibleName ();