Bump for 3.6-28
[LibreOffice.git] / editeng / source / accessibility / AccessibleComponentBase.cxx
blob3f39d0e4fc7d25b2f9f266e4e8c8ea3e48d24a9a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
31 #include <editeng/AccessibleComponentBase.hxx>
33 #include <com/sun/star/accessibility/AccessibleRole.hpp>
34 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
35 #include <com/sun/star/container/XChild.hpp>
36 #include <com/sun/star/beans/XPropertySet.hpp>
37 #include <com/sun/star/drawing/XShapes.hpp>
38 #include <com/sun/star/drawing/XShapeDescriptor.hpp>
39 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
41 #include <tools/color.hxx>
43 using namespace ::rtl;
44 using namespace ::com::sun::star;
45 using namespace ::com::sun::star::accessibility;
47 namespace accessibility {
49 //===== internal ============================================================
51 AccessibleComponentBase::AccessibleComponentBase (void)
58 AccessibleComponentBase::~AccessibleComponentBase (void)
65 //===== XAccessibleComponent ================================================
67 sal_Bool SAL_CALL AccessibleComponentBase::containsPoint (
68 const ::com::sun::star::awt::Point& aPoint)
69 throw (::com::sun::star::uno::RuntimeException)
71 awt::Size aSize (getSize());
72 return (aPoint.X >= 0)
73 && (aPoint.X < aSize.Width)
74 && (aPoint.Y >= 0)
75 && (aPoint.Y < aSize.Height);
81 uno::Reference<XAccessible > SAL_CALL
82 AccessibleComponentBase::getAccessibleAtPoint (
83 const awt::Point& /*aPoint*/)
84 throw (uno::RuntimeException)
86 return uno::Reference<XAccessible>();
92 awt::Rectangle SAL_CALL AccessibleComponentBase::getBounds (void)
93 throw (uno::RuntimeException)
95 return awt::Rectangle();
101 awt::Point SAL_CALL AccessibleComponentBase::getLocation (void)
102 throw (::com::sun::star::uno::RuntimeException)
104 awt::Rectangle aBBox (getBounds());
105 return awt::Point (aBBox.X, aBBox.Y);
111 awt::Point SAL_CALL AccessibleComponentBase::getLocationOnScreen (void)
112 throw (::com::sun::star::uno::RuntimeException)
114 return awt::Point();
120 ::com::sun::star::awt::Size SAL_CALL AccessibleComponentBase::getSize (void)
121 throw (::com::sun::star::uno::RuntimeException)
123 awt::Rectangle aBBox (getBounds());
124 return awt::Size (aBBox.Width, aBBox.Height);
130 void SAL_CALL AccessibleComponentBase::addFocusListener (
131 const ::com::sun::star::uno::Reference<
132 ::com::sun::star::awt::XFocusListener >& /*xListener*/)
133 throw (::com::sun::star::uno::RuntimeException)
135 // Ignored
141 void SAL_CALL AccessibleComponentBase::removeFocusListener (const ::com::sun::star::uno::Reference<
142 ::com::sun::star::awt::XFocusListener >& /*xListener*/ )
143 throw (::com::sun::star::uno::RuntimeException)
145 // Ignored
151 void SAL_CALL AccessibleComponentBase::grabFocus (void)
152 throw (::com::sun::star::uno::RuntimeException)
154 uno::Reference<XAccessibleContext> xContext (this, uno::UNO_QUERY);
155 uno::Reference<XAccessibleSelection> xSelection (
156 xContext->getAccessibleParent(), uno::UNO_QUERY);
157 if (xSelection.is())
159 // Do a single selection on this object.
160 xSelection->clearAccessibleSelection();
161 xSelection->selectAccessibleChild (xContext->getAccessibleIndexInParent());
168 sal_Int32 SAL_CALL AccessibleComponentBase::getForeground (void)
169 throw (::com::sun::star::uno::RuntimeException)
171 return Color(COL_BLACK).GetColor();
177 sal_Int32 SAL_CALL AccessibleComponentBase::getBackground (void)
178 throw (::com::sun::star::uno::RuntimeException)
180 return Color(COL_WHITE).GetColor();
186 //===== XAccessibleExtendedComponent ========================================
188 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL
189 AccessibleComponentBase::getFont (void)
190 throw (::com::sun::star::uno::RuntimeException)
192 return uno::Reference<awt::XFont>();
198 ::rtl::OUString SAL_CALL AccessibleComponentBase::getTitledBorderText (void)
199 throw (::com::sun::star::uno::RuntimeException)
201 return ::rtl::OUString ("");
207 ::rtl::OUString SAL_CALL AccessibleComponentBase::getToolTipText (void)
208 throw (::com::sun::star::uno::RuntimeException)
210 return ::rtl::OUString ("");
216 //===== XTypeProvider ===================================================
218 uno::Sequence<uno::Type> SAL_CALL
219 AccessibleComponentBase::getTypes (void)
220 throw (uno::RuntimeException)
222 // Get list of types from the context base implementation...
223 uno::Sequence<uno::Type> aTypeList (2);
224 // ...and add the additional type for the component.
225 const uno::Type aComponentType =
226 ::getCppuType((const uno::Reference<XAccessibleComponent>*)0);
227 const uno::Type aExtendedComponentType =
228 ::getCppuType((const uno::Reference<XAccessibleExtendedComponent>*)0);
229 aTypeList[0] = aComponentType;
230 aTypeList[1] = aExtendedComponentType;
232 return aTypeList;
236 } // end of namespace accessibility
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */