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