1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f6e50924SAndrew Rist  * distributed with this work for additional information
6*f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f6e50924SAndrew Rist  *
11*f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f6e50924SAndrew Rist  *
13*f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f6e50924SAndrew Rist  * specific language governing permissions and limitations
18*f6e50924SAndrew Rist  * under the License.
19*f6e50924SAndrew Rist  *
20*f6e50924SAndrew Rist  *************************************************************/
21*f6e50924SAndrew Rist 
22*f6e50924SAndrew 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>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir using namespace ::accessibility;
34cdf0e10cSrcweir using namespace ::rtl;
35cdf0e10cSrcweir using namespace ::com::sun::star;
36cdf0e10cSrcweir using namespace	::com::sun::star::accessibility;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //=====  internal  ============================================================
39cdf0e10cSrcweir 
40cdf0e10cSrcweir AccessibleGraphicShape::AccessibleGraphicShape (
41cdf0e10cSrcweir     const AccessibleShapeInfo& rShapeInfo,
42cdf0e10cSrcweir     const AccessibleShapeTreeInfo& rShapeTreeInfo)
43cdf0e10cSrcweir     : AccessibleShape (rShapeInfo, rShapeTreeInfo)
44cdf0e10cSrcweir {
45cdf0e10cSrcweir }
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 
50cdf0e10cSrcweir AccessibleGraphicShape::~AccessibleGraphicShape (void)
51cdf0e10cSrcweir {
52cdf0e10cSrcweir }
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 
56cdf0e10cSrcweir 
57cdf0e10cSrcweir //=====  XAccessibleImage  ====================================================
58cdf0e10cSrcweir 
59cdf0e10cSrcweir ::rtl::OUString SAL_CALL AccessibleGraphicShape::getAccessibleImageDescription (void)
60cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
61cdf0e10cSrcweir {
62cdf0e10cSrcweir     return AccessibleShape::getAccessibleDescription ();
63cdf0e10cSrcweir }
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 
68cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleGraphicShape::getAccessibleImageHeight (void)
69cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
70cdf0e10cSrcweir {
71cdf0e10cSrcweir     return AccessibleShape::getSize().Height;
72cdf0e10cSrcweir }
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 
77cdf0e10cSrcweir sal_Int32 SAL_CALL AccessibleGraphicShape::getAccessibleImageWidth (void)
78cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
79cdf0e10cSrcweir {
80cdf0e10cSrcweir     return AccessibleShape::getSize().Width;
81cdf0e10cSrcweir }
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 
86cdf0e10cSrcweir //=====  XInterface  ==========================================================
87cdf0e10cSrcweir 
88cdf0e10cSrcweir com::sun::star::uno::Any SAL_CALL
89cdf0e10cSrcweir     AccessibleGraphicShape::queryInterface (const com::sun::star::uno::Type & rType)
90cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
91cdf0e10cSrcweir {
92cdf0e10cSrcweir     ::com::sun::star::uno::Any aReturn = AccessibleShape::queryInterface (rType);
93cdf0e10cSrcweir     if ( ! aReturn.hasValue())
94cdf0e10cSrcweir         aReturn = ::cppu::queryInterface (rType,
95cdf0e10cSrcweir             static_cast<XAccessibleImage*>(this));
96cdf0e10cSrcweir     return aReturn;
97cdf0e10cSrcweir }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 
101cdf0e10cSrcweir void SAL_CALL
102cdf0e10cSrcweir     AccessibleGraphicShape::acquire (void)
103cdf0e10cSrcweir     throw ()
104cdf0e10cSrcweir {
105cdf0e10cSrcweir     AccessibleShape::acquire ();
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 
110cdf0e10cSrcweir void SAL_CALL
111cdf0e10cSrcweir     AccessibleGraphicShape::release (void)
112cdf0e10cSrcweir     throw ()
113cdf0e10cSrcweir {
114cdf0e10cSrcweir     AccessibleShape::release ();
115cdf0e10cSrcweir }
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 
120cdf0e10cSrcweir //=====  XServiceInfo  ========================================================
121cdf0e10cSrcweir 
122cdf0e10cSrcweir ::rtl::OUString SAL_CALL
123cdf0e10cSrcweir     AccessibleGraphicShape::getImplementationName (void)
124cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
125cdf0e10cSrcweir {
126cdf0e10cSrcweir 	return ::rtl::OUString(
127cdf0e10cSrcweir         RTL_CONSTASCII_USTRINGPARAM("AccessibleGraphicShape"));
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 
133cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL
134cdf0e10cSrcweir     AccessibleGraphicShape::getSupportedServiceNames (void)
135cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
136cdf0e10cSrcweir {
137cdf0e10cSrcweir     ThrowIfDisposed ();
138cdf0e10cSrcweir     // Get list of supported service names from base class...
139cdf0e10cSrcweir     uno::Sequence<OUString> aServiceNames =
140cdf0e10cSrcweir         AccessibleShape::getSupportedServiceNames();
141cdf0e10cSrcweir     sal_Int32 nCount (aServiceNames.getLength());
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     // ...and add additional names.
144cdf0e10cSrcweir     aServiceNames.realloc (nCount + 1);
145cdf0e10cSrcweir     static const OUString sAdditionalServiceName (RTL_CONSTASCII_USTRINGPARAM(
146cdf0e10cSrcweir         "com.sun.star.drawing.AccessibleGraphicShape"));
147cdf0e10cSrcweir     aServiceNames[nCount] = sAdditionalServiceName;
148cdf0e10cSrcweir 
149cdf0e10cSrcweir     return aServiceNames;
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 
155cdf0e10cSrcweir //=====  XTypeProvider  ===================================================
156cdf0e10cSrcweir 
157cdf0e10cSrcweir uno::Sequence<uno::Type> SAL_CALL
158cdf0e10cSrcweir     AccessibleGraphicShape::getTypes (void)
159cdf0e10cSrcweir     throw (uno::RuntimeException)
160cdf0e10cSrcweir {
161cdf0e10cSrcweir     // Get list of types from the context base implementation...
162cdf0e10cSrcweir 	uno::Sequence<uno::Type> aTypeList (AccessibleShape::getTypes());
163cdf0e10cSrcweir     // ...and add the additional type for the component.
164cdf0e10cSrcweir     long nTypeCount = aTypeList.getLength();
165cdf0e10cSrcweir     aTypeList.realloc (nTypeCount + 1);
166cdf0e10cSrcweir     const uno::Type aImageType =
167cdf0e10cSrcweir     	::getCppuType((const uno::Reference<XAccessibleImage>*)0);
168cdf0e10cSrcweir     aTypeList[nTypeCount] = aImageType;
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 	return aTypeList;
171cdf0e10cSrcweir }
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 
176cdf0e10cSrcweir ///	Create the base name of this object, i.e. the name without appended number.
177cdf0e10cSrcweir ::rtl::OUString
178cdf0e10cSrcweir     AccessibleGraphicShape::CreateAccessibleBaseName (void)
179cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
180cdf0e10cSrcweir {
181cdf0e10cSrcweir     ::rtl::OUString sName;
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     ShapeTypeId nShapeType = ShapeTypeHandler::Instance().GetTypeId (mxShape);
184cdf0e10cSrcweir     switch (nShapeType)
185cdf0e10cSrcweir     {
186cdf0e10cSrcweir         case DRAWING_GRAPHIC_OBJECT:
187cdf0e10cSrcweir             sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("GraphicObjectShape"));
188cdf0e10cSrcweir             break;
189cdf0e10cSrcweir 
190cdf0e10cSrcweir         default:
191cdf0e10cSrcweir             sName = ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM("UnknownAccessibleGraphicShape"));
192cdf0e10cSrcweir             uno::Reference<drawing::XShapeDescriptor> xDescriptor (mxShape, uno::UNO_QUERY);
193cdf0e10cSrcweir             if (xDescriptor.is())
194cdf0e10cSrcweir                 sName += ::rtl::OUString (RTL_CONSTASCII_USTRINGPARAM(": "))
195cdf0e10cSrcweir                     + xDescriptor->getShapeType();
196cdf0e10cSrcweir     }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     return sName;
199cdf0e10cSrcweir }
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 
203cdf0e10cSrcweir ::rtl::OUString
204cdf0e10cSrcweir     AccessibleGraphicShape::CreateAccessibleDescription (void)
205cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
206cdf0e10cSrcweir {
207cdf0e10cSrcweir     return CreateAccessibleName ();
208cdf0e10cSrcweir }
209