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_editeng.hxx"
30 
31 
32 #include <editeng/AccessibleComponentBase.hxx>
33 
34 #include <com/sun/star/accessibility/AccessibleRole.hpp>
35 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
36 #include <com/sun/star/container/XChild.hpp>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <com/sun/star/drawing/XShapes.hpp>
39 #include <com/sun/star/drawing/XShapeDescriptor.hpp>
40 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
41 
42 #include <tools/color.hxx>
43 
44 using namespace ::rtl;
45 using namespace ::com::sun::star;
46 using namespace	::com::sun::star::accessibility;
47 
48 namespace accessibility {
49 
50 //=====  internal  ============================================================
51 
52 AccessibleComponentBase::AccessibleComponentBase (void)
53 {
54 }
55 
56 
57 
58 
59 AccessibleComponentBase::~AccessibleComponentBase (void)
60 {
61 }
62 
63 
64 
65 
66 //=====  XAccessibleComponent  ================================================
67 
68 sal_Bool SAL_CALL AccessibleComponentBase::containsPoint (
69         const ::com::sun::star::awt::Point& aPoint)
70         throw (::com::sun::star::uno::RuntimeException)
71 {
72     awt::Size aSize (getSize());
73     return (aPoint.X >= 0)
74         && (aPoint.X < aSize.Width)
75         && (aPoint.Y >= 0)
76         && (aPoint.Y < aSize.Height);
77 }
78 
79 
80 
81 
82 uno::Reference<XAccessible > SAL_CALL
83     AccessibleComponentBase::getAccessibleAtPoint (
84         const awt::Point& /*aPoint*/)
85     throw (uno::RuntimeException)
86 {
87     return uno::Reference<XAccessible>();
88 }
89 
90 
91 
92 
93 awt::Rectangle SAL_CALL AccessibleComponentBase::getBounds (void)
94     throw (uno::RuntimeException)
95 {
96     return awt::Rectangle();
97 }
98 
99 
100 
101 
102 awt::Point SAL_CALL AccessibleComponentBase::getLocation (void)
103     throw (::com::sun::star::uno::RuntimeException)
104 {
105     awt::Rectangle aBBox (getBounds());
106     return awt::Point (aBBox.X, aBBox.Y);
107 }
108 
109 
110 
111 
112 awt::Point SAL_CALL AccessibleComponentBase::getLocationOnScreen (void)
113     throw (::com::sun::star::uno::RuntimeException)
114 {
115     return awt::Point();
116 }
117 
118 
119 
120 
121 ::com::sun::star::awt::Size SAL_CALL AccessibleComponentBase::getSize (void)
122     throw (::com::sun::star::uno::RuntimeException)
123 {
124     awt::Rectangle aBBox (getBounds());
125     return awt::Size (aBBox.Width, aBBox.Height);
126 }
127 
128 
129 
130 
131 void SAL_CALL AccessibleComponentBase::addFocusListener (
132     const ::com::sun::star::uno::Reference<
133     ::com::sun::star::awt::XFocusListener >& /*xListener*/)
134     throw (::com::sun::star::uno::RuntimeException)
135 {
136     // Ignored
137 }
138 
139 
140 
141 
142 void SAL_CALL AccessibleComponentBase::removeFocusListener (const ::com::sun::star::uno::Reference<
143     ::com::sun::star::awt::XFocusListener >& /*xListener*/ )
144     throw (::com::sun::star::uno::RuntimeException)
145 {
146     // Ignored
147 }
148 
149 
150 
151 
152 void SAL_CALL AccessibleComponentBase::grabFocus (void)
153     throw (::com::sun::star::uno::RuntimeException)
154 {
155     uno::Reference<XAccessibleContext> xContext (this, uno::UNO_QUERY);
156     uno::Reference<XAccessibleSelection> xSelection (
157         xContext->getAccessibleParent(), uno::UNO_QUERY);
158     if (xSelection.is())
159     {
160         // Do a single selection on this object.
161         xSelection->clearAccessibleSelection();
162         xSelection->selectAccessibleChild (xContext->getAccessibleIndexInParent());
163     }
164 }
165 
166 
167 
168 
169 sal_Int32 SAL_CALL AccessibleComponentBase::getForeground (void)
170         throw (::com::sun::star::uno::RuntimeException)
171 {
172     return Color(COL_BLACK).GetColor();
173 }
174 
175 
176 
177 
178 sal_Int32 SAL_CALL AccessibleComponentBase::getBackground (void)
179     throw (::com::sun::star::uno::RuntimeException)
180 {
181     return Color(COL_WHITE).GetColor();
182 }
183 
184 
185 
186 
187 //=====  XAccessibleExtendedComponent  ========================================
188 
189 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL
190         AccessibleComponentBase::getFont (void)
191         throw (::com::sun::star::uno::RuntimeException)
192 {
193     return uno::Reference<awt::XFont>();
194 }
195 
196 
197 
198 
199 ::rtl::OUString SAL_CALL AccessibleComponentBase::getTitledBorderText (void)
200         throw (::com::sun::star::uno::RuntimeException)
201 {
202     return ::rtl::OUString::createFromAscii ("");
203 }
204 
205 
206 
207 
208 ::rtl::OUString SAL_CALL AccessibleComponentBase::getToolTipText (void)
209     throw (::com::sun::star::uno::RuntimeException)
210 {
211     return ::rtl::OUString::createFromAscii ("");
212 }
213 
214 
215 
216 
217 //=====  XTypeProvider  ===================================================
218 
219 uno::Sequence<uno::Type> SAL_CALL
220     AccessibleComponentBase::getTypes (void)
221     throw (uno::RuntimeException)
222 {
223     // Get list of types from the context base implementation...
224 	uno::Sequence<uno::Type> aTypeList (2);
225     // ...and add the additional type for the component.
226     const uno::Type aComponentType =
227      	::getCppuType((const uno::Reference<XAccessibleComponent>*)0);
228     const uno::Type aExtendedComponentType =
229     	::getCppuType((const uno::Reference<XAccessibleExtendedComponent>*)0);
230     aTypeList[0] = aComponentType;
231     aTypeList[1] = aExtendedComponentType;
232 
233 	return aTypeList;
234 }
235 
236 
237 } // end of namespace accessibility
238