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