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