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