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