1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleComponentBase.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
35 #include <svx/AccessibleComponentBase.hxx>
37 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLE_ROLE_HPP_
38 #include <com/sun/star/accessibility/AccessibleRole.hpp>
40 #ifndef _COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLE_SELECTION_HPP_
41 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
43 #include <com/sun/star/container/XChild.hpp>
44 #include <com/sun/star/beans/XPropertySet.hpp>
45 #include <com/sun/star/drawing/XShapes.hpp>
46 #include <com/sun/star/drawing/XShapeDescriptor.hpp>
47 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
48 #include <tools/color.hxx>
50 using namespace ::rtl
;
51 using namespace ::com::sun::star
;
52 using namespace ::com::sun::star::accessibility
;
54 namespace accessibility
{
56 //===== internal ============================================================
58 AccessibleComponentBase::AccessibleComponentBase (void)
65 AccessibleComponentBase::~AccessibleComponentBase (void)
72 //===== XAccessibleComponent ================================================
74 sal_Bool SAL_CALL
AccessibleComponentBase::containsPoint (
75 const ::com::sun::star::awt::Point
& aPoint
)
76 throw (::com::sun::star::uno::RuntimeException
)
78 awt::Size
aSize (getSize());
79 return (aPoint
.X
>= 0)
80 && (aPoint
.X
< aSize
.Width
)
82 && (aPoint
.Y
< aSize
.Height
);
88 uno::Reference
<XAccessible
> SAL_CALL
89 AccessibleComponentBase::getAccessibleAtPoint (
90 const awt::Point
& /*aPoint*/)
91 throw (uno::RuntimeException
)
93 return uno::Reference
<XAccessible
>();
99 awt::Rectangle SAL_CALL
AccessibleComponentBase::getBounds (void)
100 throw (uno::RuntimeException
)
102 return awt::Rectangle();
108 awt::Point SAL_CALL
AccessibleComponentBase::getLocation (void)
109 throw (::com::sun::star::uno::RuntimeException
)
111 awt::Rectangle
aBBox (getBounds());
112 return awt::Point (aBBox
.X
, aBBox
.Y
);
118 awt::Point SAL_CALL
AccessibleComponentBase::getLocationOnScreen (void)
119 throw (::com::sun::star::uno::RuntimeException
)
127 ::com::sun::star::awt::Size SAL_CALL
AccessibleComponentBase::getSize (void)
128 throw (::com::sun::star::uno::RuntimeException
)
130 awt::Rectangle
aBBox (getBounds());
131 return awt::Size (aBBox
.Width
, aBBox
.Height
);
137 void SAL_CALL
AccessibleComponentBase::addFocusListener (
138 const ::com::sun::star::uno::Reference
<
139 ::com::sun::star::awt::XFocusListener
>& /*xListener*/)
140 throw (::com::sun::star::uno::RuntimeException
)
148 void SAL_CALL
AccessibleComponentBase::removeFocusListener (const ::com::sun::star::uno::Reference
<
149 ::com::sun::star::awt::XFocusListener
>& /*xListener*/ )
150 throw (::com::sun::star::uno::RuntimeException
)
158 void SAL_CALL
AccessibleComponentBase::grabFocus (void)
159 throw (::com::sun::star::uno::RuntimeException
)
161 uno::Reference
<XAccessibleContext
> xContext (this, uno::UNO_QUERY
);
162 uno::Reference
<XAccessibleSelection
> xSelection (
163 xContext
->getAccessibleParent(), uno::UNO_QUERY
);
166 // Do a single selection on this object.
167 xSelection
->clearAccessibleSelection();
168 xSelection
->selectAccessibleChild (xContext
->getAccessibleIndexInParent());
175 sal_Int32 SAL_CALL
AccessibleComponentBase::getForeground (void)
176 throw (::com::sun::star::uno::RuntimeException
)
178 return Color(COL_BLACK
).GetColor();
184 sal_Int32 SAL_CALL
AccessibleComponentBase::getBackground (void)
185 throw (::com::sun::star::uno::RuntimeException
)
187 return Color(COL_WHITE
).GetColor();
193 //===== XAccessibleExtendedComponent ========================================
195 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XFont
> SAL_CALL
196 AccessibleComponentBase::getFont (void)
197 throw (::com::sun::star::uno::RuntimeException
)
199 return uno::Reference
<awt::XFont
>();
205 ::rtl::OUString SAL_CALL
AccessibleComponentBase::getTitledBorderText (void)
206 throw (::com::sun::star::uno::RuntimeException
)
208 return ::rtl::OUString::createFromAscii ("");
214 ::rtl::OUString SAL_CALL
AccessibleComponentBase::getToolTipText (void)
215 throw (::com::sun::star::uno::RuntimeException
)
217 return ::rtl::OUString::createFromAscii ("");
223 //===== XTypeProvider ===================================================
225 uno::Sequence
<uno::Type
> SAL_CALL
226 AccessibleComponentBase::getTypes (void)
227 throw (uno::RuntimeException
)
229 // Get list of types from the context base implementation...
230 uno::Sequence
<uno::Type
> aTypeList (2);
231 // ...and add the additional type for the component.
232 const uno::Type aComponentType
=
233 ::getCppuType((const uno::Reference
<XAccessibleComponent
>*)0);
234 const uno::Type aExtendedComponentType
=
235 ::getCppuType((const uno::Reference
<XAccessibleExtendedComponent
>*)0);
236 aTypeList
[0] = aComponentType
;
237 aTypeList
[1] = aExtendedComponentType
;
243 } // end of namespace accessibility