xref: /AOO41X/main/chart2/source/controller/accessibility/AccessibleChartShape.cxx (revision cde9e8dc2218e857da4894ecba5c903312256674)
1*cde9e8dcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*cde9e8dcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*cde9e8dcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*cde9e8dcSAndrew Rist  * distributed with this work for additional information
6*cde9e8dcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*cde9e8dcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*cde9e8dcSAndrew Rist  * "License"); you may not use this file except in compliance
9*cde9e8dcSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*cde9e8dcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*cde9e8dcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*cde9e8dcSAndrew Rist  * software distributed under the License is distributed on an
15*cde9e8dcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*cde9e8dcSAndrew Rist  * KIND, either express or implied.  See the License for the
17*cde9e8dcSAndrew Rist  * specific language governing permissions and limitations
18*cde9e8dcSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*cde9e8dcSAndrew Rist  *************************************************************/
21*cde9e8dcSAndrew Rist 
22*cde9e8dcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_chart2.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "AccessibleChartShape.hxx"
28cdf0e10cSrcweir #include "ObjectHierarchy.hxx"
29cdf0e10cSrcweir #include "ObjectIdentifier.hxx"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
32cdf0e10cSrcweir #include <svx/ShapeTypeHandler.hxx>
33cdf0e10cSrcweir #include <svx/AccessibleShape.hxx>
34cdf0e10cSrcweir #include <svx/AccessibleShapeInfo.hxx>
35cdf0e10cSrcweir 
36cdf0e10cSrcweir using namespace ::com::sun::star;
37cdf0e10cSrcweir using namespace ::com::sun::star::accessibility;
38cdf0e10cSrcweir 
39cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
40cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException;
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 
43cdf0e10cSrcweir namespace chart
44cdf0e10cSrcweir {
45cdf0e10cSrcweir 
AccessibleChartShape(const AccessibleElementInfo & rAccInfo,bool bMayHaveChildren,bool bAlwaysTransparent)46cdf0e10cSrcweir AccessibleChartShape::AccessibleChartShape(
47cdf0e10cSrcweir         const AccessibleElementInfo& rAccInfo,
48cdf0e10cSrcweir         bool bMayHaveChildren, bool bAlwaysTransparent )
49cdf0e10cSrcweir     :impl::AccessibleChartShape_Base( rAccInfo, bMayHaveChildren, bAlwaysTransparent )
50cdf0e10cSrcweir     ,m_pAccShape( NULL )
51cdf0e10cSrcweir {
52cdf0e10cSrcweir     if ( rAccInfo.m_aOID.isAdditionalShape() )
53cdf0e10cSrcweir     {
54cdf0e10cSrcweir         Reference< drawing::XShape > xShape( rAccInfo.m_aOID.getAdditionalShape() );
55cdf0e10cSrcweir         Reference< XAccessible > xParent;
56cdf0e10cSrcweir         if ( rAccInfo.m_pParent )
57cdf0e10cSrcweir         {
58cdf0e10cSrcweir             xParent.set( rAccInfo.m_pParent );
59cdf0e10cSrcweir         }
60cdf0e10cSrcweir         sal_Int32 nIndex = -1;
61cdf0e10cSrcweir         if ( rAccInfo.m_spObjectHierarchy )
62cdf0e10cSrcweir         {
63cdf0e10cSrcweir             nIndex = rAccInfo.m_spObjectHierarchy->getIndexInParent( rAccInfo.m_aOID );
64cdf0e10cSrcweir         }
65cdf0e10cSrcweir         ::accessibility::AccessibleShapeInfo aShapeInfo( xShape, xParent, nIndex );
66cdf0e10cSrcweir 
67cdf0e10cSrcweir         m_aShapeTreeInfo.SetSdrView( rAccInfo.m_pSdrView );
68cdf0e10cSrcweir         m_aShapeTreeInfo.SetController( NULL );
69cdf0e10cSrcweir         m_aShapeTreeInfo.SetWindow( VCLUnoHelper::GetWindow( rAccInfo.m_xWindow ) );
70cdf0e10cSrcweir         m_aShapeTreeInfo.SetViewForwarder( rAccInfo.m_pViewForwarder );
71cdf0e10cSrcweir 
72cdf0e10cSrcweir         ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance();
73cdf0e10cSrcweir         m_pAccShape = rShapeHandler.CreateAccessibleObject( aShapeInfo, m_aShapeTreeInfo );
74cdf0e10cSrcweir         if ( m_pAccShape )
75cdf0e10cSrcweir         {
76cdf0e10cSrcweir             m_pAccShape->acquire();
77cdf0e10cSrcweir             m_pAccShape->Init();
78cdf0e10cSrcweir         }
79cdf0e10cSrcweir     }
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
~AccessibleChartShape()82cdf0e10cSrcweir AccessibleChartShape::~AccessibleChartShape()
83cdf0e10cSrcweir {
84cdf0e10cSrcweir     OSL_ASSERT( CheckDisposeState( false /* don't throw exceptions */ ) );
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     if ( m_pAccShape )
87cdf0e10cSrcweir     {
88cdf0e10cSrcweir         m_pAccShape->dispose();
89cdf0e10cSrcweir         m_pAccShape->release();
90cdf0e10cSrcweir     }
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir // ________ XServiceInfo ________
getImplementationName()94cdf0e10cSrcweir ::rtl::OUString AccessibleChartShape::getImplementationName()
95cdf0e10cSrcweir     throw (RuntimeException)
96cdf0e10cSrcweir {
97cdf0e10cSrcweir     return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AccessibleChartShape" ) );
98cdf0e10cSrcweir }
99cdf0e10cSrcweir 
100cdf0e10cSrcweir // ________ XAccessibleContext ________
getAccessibleChildCount()101cdf0e10cSrcweir sal_Int32 AccessibleChartShape::getAccessibleChildCount()
102cdf0e10cSrcweir     throw (RuntimeException)
103cdf0e10cSrcweir {
104cdf0e10cSrcweir     sal_Int32 nCount(0);
105cdf0e10cSrcweir     if ( m_pAccShape )
106cdf0e10cSrcweir     {
107cdf0e10cSrcweir         nCount = m_pAccShape->getAccessibleChildCount();
108cdf0e10cSrcweir     }
109cdf0e10cSrcweir     return nCount;
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
getAccessibleChild(sal_Int32 i)112cdf0e10cSrcweir Reference< XAccessible > AccessibleChartShape::getAccessibleChild( sal_Int32 i )
113cdf0e10cSrcweir     throw (lang::IndexOutOfBoundsException, RuntimeException)
114cdf0e10cSrcweir {
115cdf0e10cSrcweir     Reference< XAccessible > xChild;
116cdf0e10cSrcweir     if ( m_pAccShape )
117cdf0e10cSrcweir     {
118cdf0e10cSrcweir         xChild = m_pAccShape->getAccessibleChild( i );
119cdf0e10cSrcweir     }
120cdf0e10cSrcweir     return xChild;
121cdf0e10cSrcweir }
122cdf0e10cSrcweir 
getAccessibleRole()123cdf0e10cSrcweir sal_Int16 AccessibleChartShape::getAccessibleRole()
124cdf0e10cSrcweir     throw (RuntimeException)
125cdf0e10cSrcweir {
126cdf0e10cSrcweir     sal_Int16 nRole(0);
127cdf0e10cSrcweir     if ( m_pAccShape )
128cdf0e10cSrcweir     {
129cdf0e10cSrcweir         nRole = m_pAccShape->getAccessibleRole();
130cdf0e10cSrcweir     }
131cdf0e10cSrcweir     return nRole;
132cdf0e10cSrcweir }
133cdf0e10cSrcweir 
getAccessibleDescription()134cdf0e10cSrcweir ::rtl::OUString AccessibleChartShape::getAccessibleDescription()
135cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
136cdf0e10cSrcweir {
137cdf0e10cSrcweir     ::rtl::OUString aDescription;
138cdf0e10cSrcweir     if ( m_pAccShape )
139cdf0e10cSrcweir     {
140cdf0e10cSrcweir         aDescription = m_pAccShape->getAccessibleDescription();
141cdf0e10cSrcweir     }
142cdf0e10cSrcweir     return aDescription;
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
getAccessibleName()145cdf0e10cSrcweir ::rtl::OUString AccessibleChartShape::getAccessibleName()
146cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
147cdf0e10cSrcweir {
148cdf0e10cSrcweir     ::rtl::OUString aName;
149cdf0e10cSrcweir     if ( m_pAccShape )
150cdf0e10cSrcweir     {
151cdf0e10cSrcweir         aName = m_pAccShape->getAccessibleName();
152cdf0e10cSrcweir     }
153cdf0e10cSrcweir     return aName;
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir // ________ XAccessibleComponent ________
containsPoint(const awt::Point & aPoint)157cdf0e10cSrcweir sal_Bool AccessibleChartShape::containsPoint( const awt::Point& aPoint )
158cdf0e10cSrcweir     throw (uno::RuntimeException)
159cdf0e10cSrcweir {
160cdf0e10cSrcweir     sal_Bool bReturn = sal_False;
161cdf0e10cSrcweir     if ( m_pAccShape )
162cdf0e10cSrcweir     {
163cdf0e10cSrcweir         bReturn = m_pAccShape->containsPoint( aPoint );
164cdf0e10cSrcweir     }
165cdf0e10cSrcweir     return bReturn;
166cdf0e10cSrcweir }
167cdf0e10cSrcweir 
getAccessibleAtPoint(const awt::Point & aPoint)168cdf0e10cSrcweir Reference< XAccessible > AccessibleChartShape::getAccessibleAtPoint( const awt::Point& aPoint )
169cdf0e10cSrcweir     throw (uno::RuntimeException)
170cdf0e10cSrcweir {
171cdf0e10cSrcweir     Reference< XAccessible > xResult;
172cdf0e10cSrcweir     if ( m_pAccShape )
173cdf0e10cSrcweir     {
174cdf0e10cSrcweir         xResult.set( m_pAccShape->getAccessibleAtPoint( aPoint ) );
175cdf0e10cSrcweir     }
176cdf0e10cSrcweir     return xResult;
177cdf0e10cSrcweir }
178cdf0e10cSrcweir 
getBounds()179cdf0e10cSrcweir awt::Rectangle AccessibleChartShape::getBounds()
180cdf0e10cSrcweir     throw (uno::RuntimeException)
181cdf0e10cSrcweir {
182cdf0e10cSrcweir     awt::Rectangle aBounds;
183cdf0e10cSrcweir     if ( m_pAccShape )
184cdf0e10cSrcweir     {
185cdf0e10cSrcweir         aBounds = m_pAccShape->getBounds();
186cdf0e10cSrcweir     }
187cdf0e10cSrcweir     return aBounds;
188cdf0e10cSrcweir }
189cdf0e10cSrcweir 
getLocation()190cdf0e10cSrcweir awt::Point AccessibleChartShape::getLocation()
191cdf0e10cSrcweir     throw (uno::RuntimeException)
192cdf0e10cSrcweir {
193cdf0e10cSrcweir     awt::Point aLocation;
194cdf0e10cSrcweir     if ( m_pAccShape )
195cdf0e10cSrcweir     {
196cdf0e10cSrcweir         aLocation = m_pAccShape->getLocation();
197cdf0e10cSrcweir     }
198cdf0e10cSrcweir     return aLocation;
199cdf0e10cSrcweir }
200cdf0e10cSrcweir 
getLocationOnScreen()201cdf0e10cSrcweir awt::Point AccessibleChartShape::getLocationOnScreen()
202cdf0e10cSrcweir     throw (uno::RuntimeException)
203cdf0e10cSrcweir {
204cdf0e10cSrcweir     awt::Point aLocation;
205cdf0e10cSrcweir     if ( m_pAccShape )
206cdf0e10cSrcweir     {
207cdf0e10cSrcweir         aLocation = m_pAccShape->getLocationOnScreen();
208cdf0e10cSrcweir     }
209cdf0e10cSrcweir     return aLocation;
210cdf0e10cSrcweir }
211cdf0e10cSrcweir 
getSize()212cdf0e10cSrcweir awt::Size AccessibleChartShape::getSize()
213cdf0e10cSrcweir     throw (uno::RuntimeException)
214cdf0e10cSrcweir {
215cdf0e10cSrcweir     awt::Size aSize;
216cdf0e10cSrcweir     if ( m_pAccShape )
217cdf0e10cSrcweir     {
218cdf0e10cSrcweir         aSize = m_pAccShape->getSize();
219cdf0e10cSrcweir     }
220cdf0e10cSrcweir     return aSize;
221cdf0e10cSrcweir }
222cdf0e10cSrcweir 
grabFocus()223cdf0e10cSrcweir void AccessibleChartShape::grabFocus()
224cdf0e10cSrcweir     throw (uno::RuntimeException)
225cdf0e10cSrcweir {
226cdf0e10cSrcweir     return AccessibleBase::grabFocus();
227cdf0e10cSrcweir }
228cdf0e10cSrcweir 
getForeground()229cdf0e10cSrcweir sal_Int32 AccessibleChartShape::getForeground()
230cdf0e10cSrcweir     throw (uno::RuntimeException)
231cdf0e10cSrcweir {
232cdf0e10cSrcweir     sal_Int32 nColor(0);
233cdf0e10cSrcweir     if ( m_pAccShape )
234cdf0e10cSrcweir     {
235cdf0e10cSrcweir         nColor = m_pAccShape->getForeground();
236cdf0e10cSrcweir     }
237cdf0e10cSrcweir     return nColor;
238cdf0e10cSrcweir }
239cdf0e10cSrcweir 
getBackground()240cdf0e10cSrcweir sal_Int32 AccessibleChartShape::getBackground()
241cdf0e10cSrcweir     throw (uno::RuntimeException)
242cdf0e10cSrcweir {
243cdf0e10cSrcweir     sal_Int32 nColor(0);
244cdf0e10cSrcweir     if ( m_pAccShape )
245cdf0e10cSrcweir     {
246cdf0e10cSrcweir         nColor = m_pAccShape->getBackground();
247cdf0e10cSrcweir     }
248cdf0e10cSrcweir     return nColor;
249cdf0e10cSrcweir }
250cdf0e10cSrcweir 
251cdf0e10cSrcweir // ________ XAccessibleExtendedComponent ________
getFont()252cdf0e10cSrcweir Reference< awt::XFont > AccessibleChartShape::getFont()
253cdf0e10cSrcweir     throw (uno::RuntimeException)
254cdf0e10cSrcweir {
255cdf0e10cSrcweir     Reference< awt::XFont > xFont;
256cdf0e10cSrcweir     if ( m_pAccShape )
257cdf0e10cSrcweir     {
258cdf0e10cSrcweir         xFont.set( m_pAccShape->getFont() );
259cdf0e10cSrcweir     }
260cdf0e10cSrcweir     return xFont;
261cdf0e10cSrcweir }
262cdf0e10cSrcweir 
getTitledBorderText()263cdf0e10cSrcweir ::rtl::OUString AccessibleChartShape::getTitledBorderText()
264cdf0e10cSrcweir     throw (uno::RuntimeException)
265cdf0e10cSrcweir {
266cdf0e10cSrcweir     ::rtl::OUString aText;
267cdf0e10cSrcweir     if ( m_pAccShape )
268cdf0e10cSrcweir     {
269cdf0e10cSrcweir         aText = m_pAccShape->getTitledBorderText();
270cdf0e10cSrcweir     }
271cdf0e10cSrcweir     return aText;
272cdf0e10cSrcweir }
273cdf0e10cSrcweir 
getToolTipText()274cdf0e10cSrcweir ::rtl::OUString AccessibleChartShape::getToolTipText()
275cdf0e10cSrcweir     throw (::com::sun::star::uno::RuntimeException)
276cdf0e10cSrcweir {
277cdf0e10cSrcweir     ::rtl::OUString aText;
278cdf0e10cSrcweir     if ( m_pAccShape )
279cdf0e10cSrcweir     {
280cdf0e10cSrcweir         aText = m_pAccShape->getToolTipText();
281cdf0e10cSrcweir     }
282cdf0e10cSrcweir     return aText;
283cdf0e10cSrcweir }
284cdf0e10cSrcweir 
285cdf0e10cSrcweir } // namespace chart
286