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_chart2.hxx"
30 
31 #include "AccessibleChartShape.hxx"
32 #include "ObjectHierarchy.hxx"
33 #include "ObjectIdentifier.hxx"
34 
35 #include <toolkit/helper/vclunohelper.hxx>
36 #include <svx/ShapeTypeHandler.hxx>
37 #include <svx/AccessibleShape.hxx>
38 #include <svx/AccessibleShapeInfo.hxx>
39 
40 using namespace ::com::sun::star;
41 using namespace ::com::sun::star::accessibility;
42 
43 using ::com::sun::star::uno::Reference;
44 using ::com::sun::star::uno::RuntimeException;
45 
46 
47 namespace chart
48 {
49 
50 AccessibleChartShape::AccessibleChartShape(
51         const AccessibleElementInfo& rAccInfo,
52         bool bMayHaveChildren, bool bAlwaysTransparent )
53     :impl::AccessibleChartShape_Base( rAccInfo, bMayHaveChildren, bAlwaysTransparent )
54     ,m_pAccShape( NULL )
55 {
56     if ( rAccInfo.m_aOID.isAdditionalShape() )
57     {
58         Reference< drawing::XShape > xShape( rAccInfo.m_aOID.getAdditionalShape() );
59         Reference< XAccessible > xParent;
60         if ( rAccInfo.m_pParent )
61         {
62             xParent.set( rAccInfo.m_pParent );
63         }
64         sal_Int32 nIndex = -1;
65         if ( rAccInfo.m_spObjectHierarchy )
66         {
67             nIndex = rAccInfo.m_spObjectHierarchy->getIndexInParent( rAccInfo.m_aOID );
68         }
69         ::accessibility::AccessibleShapeInfo aShapeInfo( xShape, xParent, nIndex );
70 
71         m_aShapeTreeInfo.SetSdrView( rAccInfo.m_pSdrView );
72         m_aShapeTreeInfo.SetController( NULL );
73         m_aShapeTreeInfo.SetWindow( VCLUnoHelper::GetWindow( rAccInfo.m_xWindow ) );
74         m_aShapeTreeInfo.SetViewForwarder( rAccInfo.m_pViewForwarder );
75 
76         ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance();
77         m_pAccShape = rShapeHandler.CreateAccessibleObject( aShapeInfo, m_aShapeTreeInfo );
78         if ( m_pAccShape )
79         {
80             m_pAccShape->acquire();
81             m_pAccShape->Init();
82         }
83     }
84 }
85 
86 AccessibleChartShape::~AccessibleChartShape()
87 {
88     OSL_ASSERT( CheckDisposeState( false /* don't throw exceptions */ ) );
89 
90     if ( m_pAccShape )
91     {
92         m_pAccShape->dispose();
93         m_pAccShape->release();
94     }
95 }
96 
97 // ________ XServiceInfo ________
98 ::rtl::OUString AccessibleChartShape::getImplementationName()
99     throw (RuntimeException)
100 {
101     return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AccessibleChartShape" ) );
102 }
103 
104 // ________ XAccessibleContext ________
105 sal_Int32 AccessibleChartShape::getAccessibleChildCount()
106     throw (RuntimeException)
107 {
108     sal_Int32 nCount(0);
109     if ( m_pAccShape )
110     {
111         nCount = m_pAccShape->getAccessibleChildCount();
112     }
113     return nCount;
114 }
115 
116 Reference< XAccessible > AccessibleChartShape::getAccessibleChild( sal_Int32 i )
117     throw (lang::IndexOutOfBoundsException, RuntimeException)
118 {
119     Reference< XAccessible > xChild;
120     if ( m_pAccShape )
121     {
122         xChild = m_pAccShape->getAccessibleChild( i );
123     }
124     return xChild;
125 }
126 
127 sal_Int16 AccessibleChartShape::getAccessibleRole()
128     throw (RuntimeException)
129 {
130     sal_Int16 nRole(0);
131     if ( m_pAccShape )
132     {
133         nRole = m_pAccShape->getAccessibleRole();
134     }
135     return nRole;
136 }
137 
138 ::rtl::OUString AccessibleChartShape::getAccessibleDescription()
139     throw (::com::sun::star::uno::RuntimeException)
140 {
141     ::rtl::OUString aDescription;
142     if ( m_pAccShape )
143     {
144         aDescription = m_pAccShape->getAccessibleDescription();
145     }
146     return aDescription;
147 }
148 
149 ::rtl::OUString AccessibleChartShape::getAccessibleName()
150     throw (::com::sun::star::uno::RuntimeException)
151 {
152     ::rtl::OUString aName;
153     if ( m_pAccShape )
154     {
155         aName = m_pAccShape->getAccessibleName();
156     }
157     return aName;
158 }
159 
160 // ________ XAccessibleComponent ________
161 sal_Bool AccessibleChartShape::containsPoint( const awt::Point& aPoint )
162     throw (uno::RuntimeException)
163 {
164     sal_Bool bReturn = sal_False;
165     if ( m_pAccShape )
166     {
167         bReturn = m_pAccShape->containsPoint( aPoint );
168     }
169     return bReturn;
170 }
171 
172 Reference< XAccessible > AccessibleChartShape::getAccessibleAtPoint( const awt::Point& aPoint )
173     throw (uno::RuntimeException)
174 {
175     Reference< XAccessible > xResult;
176     if ( m_pAccShape )
177     {
178         xResult.set( m_pAccShape->getAccessibleAtPoint( aPoint ) );
179     }
180     return xResult;
181 }
182 
183 awt::Rectangle AccessibleChartShape::getBounds()
184     throw (uno::RuntimeException)
185 {
186     awt::Rectangle aBounds;
187     if ( m_pAccShape )
188     {
189         aBounds = m_pAccShape->getBounds();
190     }
191     return aBounds;
192 }
193 
194 awt::Point AccessibleChartShape::getLocation()
195     throw (uno::RuntimeException)
196 {
197     awt::Point aLocation;
198     if ( m_pAccShape )
199     {
200         aLocation = m_pAccShape->getLocation();
201     }
202     return aLocation;
203 }
204 
205 awt::Point AccessibleChartShape::getLocationOnScreen()
206     throw (uno::RuntimeException)
207 {
208     awt::Point aLocation;
209     if ( m_pAccShape )
210     {
211         aLocation = m_pAccShape->getLocationOnScreen();
212     }
213     return aLocation;
214 }
215 
216 awt::Size AccessibleChartShape::getSize()
217     throw (uno::RuntimeException)
218 {
219     awt::Size aSize;
220     if ( m_pAccShape )
221     {
222         aSize = m_pAccShape->getSize();
223     }
224     return aSize;
225 }
226 
227 void AccessibleChartShape::grabFocus()
228     throw (uno::RuntimeException)
229 {
230     return AccessibleBase::grabFocus();
231 }
232 
233 sal_Int32 AccessibleChartShape::getForeground()
234     throw (uno::RuntimeException)
235 {
236     sal_Int32 nColor(0);
237     if ( m_pAccShape )
238     {
239         nColor = m_pAccShape->getForeground();
240     }
241     return nColor;
242 }
243 
244 sal_Int32 AccessibleChartShape::getBackground()
245     throw (uno::RuntimeException)
246 {
247     sal_Int32 nColor(0);
248     if ( m_pAccShape )
249     {
250         nColor = m_pAccShape->getBackground();
251     }
252     return nColor;
253 }
254 
255 // ________ XAccessibleExtendedComponent ________
256 Reference< awt::XFont > AccessibleChartShape::getFont()
257     throw (uno::RuntimeException)
258 {
259     Reference< awt::XFont > xFont;
260     if ( m_pAccShape )
261     {
262         xFont.set( m_pAccShape->getFont() );
263     }
264     return xFont;
265 }
266 
267 ::rtl::OUString AccessibleChartShape::getTitledBorderText()
268     throw (uno::RuntimeException)
269 {
270     ::rtl::OUString aText;
271     if ( m_pAccShape )
272     {
273         aText = m_pAccShape->getTitledBorderText();
274     }
275     return aText;
276 }
277 
278 ::rtl::OUString AccessibleChartShape::getToolTipText()
279     throw (::com::sun::star::uno::RuntimeException)
280 {
281     ::rtl::OUString aText;
282     if ( m_pAccShape )
283     {
284         aText = m_pAccShape->getToolTipText();
285     }
286     return aText;
287 }
288 
289 } // namespace chart
290