1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 
31 
32 #include <svx/AccessibleGraphicShape.hxx>
33 
34 #include <svx/ShapeTypeHandler.hxx>
35 #include <svx/SvxShapeTypes.hxx>
36 
37 using namespace ::accessibility;
38 using namespace ::rtl;
39 using namespace ::com::sun::star;
40 using namespace	::com::sun::star::accessibility;
41 
42 //=====  internal  ============================================================
43 
44 AccessibleGraphicShape::AccessibleGraphicShape (
45     const AccessibleShapeInfo& rShapeInfo,
46     const AccessibleShapeTreeInfo& rShapeTreeInfo)
47     : AccessibleShape (rShapeInfo, rShapeTreeInfo)
48 {
49 }
50 
51 
52 
53 
54 AccessibleGraphicShape::~AccessibleGraphicShape (void)
55 {
56 }
57 
58 
59 
60 
61 //=====  XAccessibleImage  ====================================================
62 
63 ::rtl::OUString SAL_CALL AccessibleGraphicShape::getAccessibleImageDescription (void)
64     throw (::com::sun::star::uno::RuntimeException)
65 {
66     return AccessibleShape::getAccessibleDescription ();
67 }
68 
69 
70 
71 
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 
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
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
106     AccessibleGraphicShape::acquire (void)
107     throw ()
108 {
109     AccessibleShape::acquire ();
110 }
111 
112 
113 
114 void SAL_CALL
115     AccessibleGraphicShape::release (void)
116     throw ()
117 {
118     AccessibleShape::release ();
119 }
120 
121 
122 
123 
124 //=====  XServiceInfo  ========================================================
125 
126 ::rtl::OUString SAL_CALL
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
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
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
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
208     AccessibleGraphicShape::CreateAccessibleDescription (void)
209     throw (::com::sun::star::uno::RuntimeException)
210 {
211     return CreateAccessibleName ();
212 }
213