xref: /AOO41X/main/chart2/source/controller/accessibility/AccessibleChartShape.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_chart2.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "AccessibleChartShape.hxx"
32*cdf0e10cSrcweir #include "ObjectHierarchy.hxx"
33*cdf0e10cSrcweir #include "ObjectIdentifier.hxx"
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
36*cdf0e10cSrcweir #include <svx/ShapeTypeHandler.hxx>
37*cdf0e10cSrcweir #include <svx/AccessibleShape.hxx>
38*cdf0e10cSrcweir #include <svx/AccessibleShapeInfo.hxx>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir using namespace ::com::sun::star;
41*cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
44*cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException;
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir namespace chart
48*cdf0e10cSrcweir {
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir AccessibleChartShape::AccessibleChartShape(
51*cdf0e10cSrcweir         const AccessibleElementInfo& rAccInfo,
52*cdf0e10cSrcweir         bool bMayHaveChildren, bool bAlwaysTransparent )
53*cdf0e10cSrcweir     :impl::AccessibleChartShape_Base( rAccInfo, bMayHaveChildren, bAlwaysTransparent )
54*cdf0e10cSrcweir     ,m_pAccShape( NULL )
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir     if ( rAccInfo.m_aOID.isAdditionalShape() )
57*cdf0e10cSrcweir     {
58*cdf0e10cSrcweir         Reference< drawing::XShape > xShape( rAccInfo.m_aOID.getAdditionalShape() );
59*cdf0e10cSrcweir         Reference< XAccessible > xParent;
60*cdf0e10cSrcweir         if ( rAccInfo.m_pParent )
61*cdf0e10cSrcweir         {
62*cdf0e10cSrcweir             xParent.set( rAccInfo.m_pParent );
63*cdf0e10cSrcweir         }
64*cdf0e10cSrcweir         sal_Int32 nIndex = -1;
65*cdf0e10cSrcweir         if ( rAccInfo.m_spObjectHierarchy )
66*cdf0e10cSrcweir         {
67*cdf0e10cSrcweir             nIndex = rAccInfo.m_spObjectHierarchy->getIndexInParent( rAccInfo.m_aOID );
68*cdf0e10cSrcweir         }
69*cdf0e10cSrcweir         ::accessibility::AccessibleShapeInfo aShapeInfo( xShape, xParent, nIndex );
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir         m_aShapeTreeInfo.SetSdrView( rAccInfo.m_pSdrView );
72*cdf0e10cSrcweir         m_aShapeTreeInfo.SetController( NULL );
73*cdf0e10cSrcweir         m_aShapeTreeInfo.SetWindow( VCLUnoHelper::GetWindow( rAccInfo.m_xWindow ) );
74*cdf0e10cSrcweir         m_aShapeTreeInfo.SetViewForwarder( rAccInfo.m_pViewForwarder );
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir         ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance();
77*cdf0e10cSrcweir         m_pAccShape = rShapeHandler.CreateAccessibleObject( aShapeInfo, m_aShapeTreeInfo );
78*cdf0e10cSrcweir         if ( m_pAccShape )
79*cdf0e10cSrcweir         {
80*cdf0e10cSrcweir             m_pAccShape->acquire();
81*cdf0e10cSrcweir             m_pAccShape->Init();
82*cdf0e10cSrcweir         }
83*cdf0e10cSrcweir     }
84*cdf0e10cSrcweir }
85*cdf0e10cSrcweir 
86*cdf0e10cSrcweir AccessibleChartShape::~AccessibleChartShape()
87*cdf0e10cSrcweir {
88*cdf0e10cSrcweir     OSL_ASSERT( CheckDisposeState( false /* don't throw exceptions */ ) );
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir     if ( m_pAccShape )
91*cdf0e10cSrcweir     {
92*cdf0e10cSrcweir         m_pAccShape->dispose();
93*cdf0e10cSrcweir         m_pAccShape->release();
94*cdf0e10cSrcweir     }
95*cdf0e10cSrcweir }
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir // ________ XServiceInfo ________
98*cdf0e10cSrcweir ::rtl::OUString AccessibleChartShape::getImplementationName()
99*cdf0e10cSrcweir     throw (RuntimeException)
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir     return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AccessibleChartShape" ) );
102*cdf0e10cSrcweir }
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir // ________ XAccessibleContext ________
105*cdf0e10cSrcweir sal_Int32 AccessibleChartShape::getAccessibleChildCount()
106*cdf0e10cSrcweir     throw (RuntimeException)
107*cdf0e10cSrcweir {
108*cdf0e10cSrcweir     sal_Int32 nCount(0);
109*cdf0e10cSrcweir     if ( m_pAccShape )
110*cdf0e10cSrcweir     {
111*cdf0e10cSrcweir         nCount = m_pAccShape->getAccessibleChildCount();
112*cdf0e10cSrcweir     }
113*cdf0e10cSrcweir     return nCount;
114*cdf0e10cSrcweir }
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir Reference< XAccessible > AccessibleChartShape::getAccessibleChild( sal_Int32 i )
117*cdf0e10cSrcweir     throw (lang::IndexOutOfBoundsException, RuntimeException)
118*cdf0e10cSrcweir {
119*cdf0e10cSrcweir     Reference< XAccessible > xChild;
120*cdf0e10cSrcweir     if ( m_pAccShape )
121*cdf0e10cSrcweir     {
122*cdf0e10cSrcweir         xChild = m_pAccShape->getAccessibleChild( i );
123*cdf0e10cSrcweir     }
124*cdf0e10cSrcweir     return xChild;
125*cdf0e10cSrcweir }
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir sal_Int16 AccessibleChartShape::getAccessibleRole()
128*cdf0e10cSrcweir     throw (RuntimeException)
129*cdf0e10cSrcweir {
130*cdf0e10cSrcweir     sal_Int16 nRole(0);
131*cdf0e10cSrcweir     if ( m_pAccShape )
132*cdf0e10cSrcweir     {
133*cdf0e10cSrcweir         nRole = m_pAccShape->getAccessibleRole();
134*cdf0e10cSrcweir     }
135*cdf0e10cSrcweir     return nRole;
136*cdf0e10cSrcweir }
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir ::rtl::OUString AccessibleChartShape::getAccessibleDescription()
139*cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
140*cdf0e10cSrcweir {
141*cdf0e10cSrcweir     ::rtl::OUString aDescription;
142*cdf0e10cSrcweir     if ( m_pAccShape )
143*cdf0e10cSrcweir     {
144*cdf0e10cSrcweir         aDescription = m_pAccShape->getAccessibleDescription();
145*cdf0e10cSrcweir     }
146*cdf0e10cSrcweir     return aDescription;
147*cdf0e10cSrcweir }
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir ::rtl::OUString AccessibleChartShape::getAccessibleName()
150*cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
151*cdf0e10cSrcweir {
152*cdf0e10cSrcweir     ::rtl::OUString aName;
153*cdf0e10cSrcweir     if ( m_pAccShape )
154*cdf0e10cSrcweir     {
155*cdf0e10cSrcweir         aName = m_pAccShape->getAccessibleName();
156*cdf0e10cSrcweir     }
157*cdf0e10cSrcweir     return aName;
158*cdf0e10cSrcweir }
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir // ________ XAccessibleComponent ________
161*cdf0e10cSrcweir sal_Bool AccessibleChartShape::containsPoint( const awt::Point& aPoint )
162*cdf0e10cSrcweir     throw (uno::RuntimeException)
163*cdf0e10cSrcweir {
164*cdf0e10cSrcweir     sal_Bool bReturn = sal_False;
165*cdf0e10cSrcweir     if ( m_pAccShape )
166*cdf0e10cSrcweir     {
167*cdf0e10cSrcweir         bReturn = m_pAccShape->containsPoint( aPoint );
168*cdf0e10cSrcweir     }
169*cdf0e10cSrcweir     return bReturn;
170*cdf0e10cSrcweir }
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir Reference< XAccessible > AccessibleChartShape::getAccessibleAtPoint( const awt::Point& aPoint )
173*cdf0e10cSrcweir     throw (uno::RuntimeException)
174*cdf0e10cSrcweir {
175*cdf0e10cSrcweir     Reference< XAccessible > xResult;
176*cdf0e10cSrcweir     if ( m_pAccShape )
177*cdf0e10cSrcweir     {
178*cdf0e10cSrcweir         xResult.set( m_pAccShape->getAccessibleAtPoint( aPoint ) );
179*cdf0e10cSrcweir     }
180*cdf0e10cSrcweir     return xResult;
181*cdf0e10cSrcweir }
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir awt::Rectangle AccessibleChartShape::getBounds()
184*cdf0e10cSrcweir     throw (uno::RuntimeException)
185*cdf0e10cSrcweir {
186*cdf0e10cSrcweir     awt::Rectangle aBounds;
187*cdf0e10cSrcweir     if ( m_pAccShape )
188*cdf0e10cSrcweir     {
189*cdf0e10cSrcweir         aBounds = m_pAccShape->getBounds();
190*cdf0e10cSrcweir     }
191*cdf0e10cSrcweir     return aBounds;
192*cdf0e10cSrcweir }
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir awt::Point AccessibleChartShape::getLocation()
195*cdf0e10cSrcweir     throw (uno::RuntimeException)
196*cdf0e10cSrcweir {
197*cdf0e10cSrcweir     awt::Point aLocation;
198*cdf0e10cSrcweir     if ( m_pAccShape )
199*cdf0e10cSrcweir     {
200*cdf0e10cSrcweir         aLocation = m_pAccShape->getLocation();
201*cdf0e10cSrcweir     }
202*cdf0e10cSrcweir     return aLocation;
203*cdf0e10cSrcweir }
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir awt::Point AccessibleChartShape::getLocationOnScreen()
206*cdf0e10cSrcweir     throw (uno::RuntimeException)
207*cdf0e10cSrcweir {
208*cdf0e10cSrcweir     awt::Point aLocation;
209*cdf0e10cSrcweir     if ( m_pAccShape )
210*cdf0e10cSrcweir     {
211*cdf0e10cSrcweir         aLocation = m_pAccShape->getLocationOnScreen();
212*cdf0e10cSrcweir     }
213*cdf0e10cSrcweir     return aLocation;
214*cdf0e10cSrcweir }
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir awt::Size AccessibleChartShape::getSize()
217*cdf0e10cSrcweir     throw (uno::RuntimeException)
218*cdf0e10cSrcweir {
219*cdf0e10cSrcweir     awt::Size aSize;
220*cdf0e10cSrcweir     if ( m_pAccShape )
221*cdf0e10cSrcweir     {
222*cdf0e10cSrcweir         aSize = m_pAccShape->getSize();
223*cdf0e10cSrcweir     }
224*cdf0e10cSrcweir     return aSize;
225*cdf0e10cSrcweir }
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir void AccessibleChartShape::grabFocus()
228*cdf0e10cSrcweir     throw (uno::RuntimeException)
229*cdf0e10cSrcweir {
230*cdf0e10cSrcweir     return AccessibleBase::grabFocus();
231*cdf0e10cSrcweir }
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir sal_Int32 AccessibleChartShape::getForeground()
234*cdf0e10cSrcweir     throw (uno::RuntimeException)
235*cdf0e10cSrcweir {
236*cdf0e10cSrcweir     sal_Int32 nColor(0);
237*cdf0e10cSrcweir     if ( m_pAccShape )
238*cdf0e10cSrcweir     {
239*cdf0e10cSrcweir         nColor = m_pAccShape->getForeground();
240*cdf0e10cSrcweir     }
241*cdf0e10cSrcweir     return nColor;
242*cdf0e10cSrcweir }
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir sal_Int32 AccessibleChartShape::getBackground()
245*cdf0e10cSrcweir     throw (uno::RuntimeException)
246*cdf0e10cSrcweir {
247*cdf0e10cSrcweir     sal_Int32 nColor(0);
248*cdf0e10cSrcweir     if ( m_pAccShape )
249*cdf0e10cSrcweir     {
250*cdf0e10cSrcweir         nColor = m_pAccShape->getBackground();
251*cdf0e10cSrcweir     }
252*cdf0e10cSrcweir     return nColor;
253*cdf0e10cSrcweir }
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir // ________ XAccessibleExtendedComponent ________
256*cdf0e10cSrcweir Reference< awt::XFont > AccessibleChartShape::getFont()
257*cdf0e10cSrcweir     throw (uno::RuntimeException)
258*cdf0e10cSrcweir {
259*cdf0e10cSrcweir     Reference< awt::XFont > xFont;
260*cdf0e10cSrcweir     if ( m_pAccShape )
261*cdf0e10cSrcweir     {
262*cdf0e10cSrcweir         xFont.set( m_pAccShape->getFont() );
263*cdf0e10cSrcweir     }
264*cdf0e10cSrcweir     return xFont;
265*cdf0e10cSrcweir }
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir ::rtl::OUString AccessibleChartShape::getTitledBorderText()
268*cdf0e10cSrcweir     throw (uno::RuntimeException)
269*cdf0e10cSrcweir {
270*cdf0e10cSrcweir     ::rtl::OUString aText;
271*cdf0e10cSrcweir     if ( m_pAccShape )
272*cdf0e10cSrcweir     {
273*cdf0e10cSrcweir         aText = m_pAccShape->getTitledBorderText();
274*cdf0e10cSrcweir     }
275*cdf0e10cSrcweir     return aText;
276*cdf0e10cSrcweir }
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir ::rtl::OUString AccessibleChartShape::getToolTipText()
279*cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
280*cdf0e10cSrcweir {
281*cdf0e10cSrcweir     ::rtl::OUString aText;
282*cdf0e10cSrcweir     if ( m_pAccShape )
283*cdf0e10cSrcweir     {
284*cdf0e10cSrcweir         aText = m_pAccShape->getToolTipText();
285*cdf0e10cSrcweir     }
286*cdf0e10cSrcweir     return aText;
287*cdf0e10cSrcweir }
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir } // namespace chart
290