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