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