bump product version to 5.0.4.1
[LibreOffice.git] / editeng / source / accessibility / AccessibleComponentBase.cxx
blob6d16b51e8b4586252aa4763f58965e8565495bb6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <editeng/AccessibleComponentBase.hxx>
22 #include <com/sun/star/accessibility/AccessibleRole.hpp>
23 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
24 #include <com/sun/star/container/XChild.hpp>
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <com/sun/star/drawing/XShapes.hpp>
27 #include <com/sun/star/drawing/XShapeDescriptor.hpp>
28 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
30 #include <tools/color.hxx>
32 using namespace ::com::sun::star;
33 using namespace ::com::sun::star::accessibility;
35 namespace accessibility {
37 // internal
39 AccessibleComponentBase::AccessibleComponentBase()
46 AccessibleComponentBase::~AccessibleComponentBase()
50 // XAccessibleComponent
52 sal_Bool SAL_CALL AccessibleComponentBase::containsPoint (
53 const ::com::sun::star::awt::Point& aPoint)
54 throw (::com::sun::star::uno::RuntimeException, std::exception)
56 awt::Size aSize (getSize());
57 return (aPoint.X >= 0)
58 && (aPoint.X < aSize.Width)
59 && (aPoint.Y >= 0)
60 && (aPoint.Y < aSize.Height);
66 uno::Reference<XAccessible > SAL_CALL
67 AccessibleComponentBase::getAccessibleAtPoint (
68 const awt::Point& /*aPoint*/)
69 throw (uno::RuntimeException, std::exception)
71 return uno::Reference<XAccessible>();
77 awt::Rectangle SAL_CALL AccessibleComponentBase::getBounds()
78 throw (uno::RuntimeException, std::exception)
80 return awt::Rectangle();
86 awt::Point SAL_CALL AccessibleComponentBase::getLocation()
87 throw (::com::sun::star::uno::RuntimeException, std::exception)
89 awt::Rectangle aBBox (getBounds());
90 return awt::Point (aBBox.X, aBBox.Y);
96 awt::Point SAL_CALL AccessibleComponentBase::getLocationOnScreen()
97 throw (::com::sun::star::uno::RuntimeException, std::exception)
99 return awt::Point();
105 ::com::sun::star::awt::Size SAL_CALL AccessibleComponentBase::getSize()
106 throw (::com::sun::star::uno::RuntimeException, std::exception)
108 awt::Rectangle aBBox (getBounds());
109 return awt::Size (aBBox.Width, aBBox.Height);
115 void SAL_CALL AccessibleComponentBase::addFocusListener (
116 const ::com::sun::star::uno::Reference<
117 ::com::sun::star::awt::XFocusListener >& /*xListener*/)
118 throw (::com::sun::star::uno::RuntimeException)
120 // Ignored
126 void SAL_CALL AccessibleComponentBase::removeFocusListener (const ::com::sun::star::uno::Reference<
127 ::com::sun::star::awt::XFocusListener >& /*xListener*/ )
128 throw (::com::sun::star::uno::RuntimeException)
130 // Ignored
136 void SAL_CALL AccessibleComponentBase::grabFocus()
137 throw (::com::sun::star::uno::RuntimeException, std::exception)
139 uno::Reference<XAccessibleContext> xContext (this, uno::UNO_QUERY);
140 uno::Reference<XAccessibleSelection> xSelection (
141 xContext->getAccessibleParent(), uno::UNO_QUERY);
142 if (xSelection.is())
144 // Do a single selection on this object.
145 xSelection->clearAccessibleSelection();
146 xSelection->selectAccessibleChild (xContext->getAccessibleIndexInParent());
153 sal_Int32 SAL_CALL AccessibleComponentBase::getForeground()
154 throw (::com::sun::star::uno::RuntimeException, std::exception)
156 return Color(COL_BLACK).GetColor();
162 sal_Int32 SAL_CALL AccessibleComponentBase::getBackground()
163 throw (::com::sun::star::uno::RuntimeException, std::exception)
165 return Color(COL_WHITE).GetColor();
171 // XAccessibleExtendedComponent
173 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL
174 AccessibleComponentBase::getFont()
175 throw (::com::sun::star::uno::RuntimeException, std::exception)
177 return uno::Reference<awt::XFont>();
183 OUString SAL_CALL AccessibleComponentBase::getTitledBorderText()
184 throw (::com::sun::star::uno::RuntimeException, std::exception)
186 return OUString();
190 OUString SAL_CALL AccessibleComponentBase::getToolTipText()
191 throw (::com::sun::star::uno::RuntimeException, std::exception)
193 return OUString();
196 // XTypeProvider
198 uno::Sequence<uno::Type> SAL_CALL
199 AccessibleComponentBase::getTypes()
200 throw (uno::RuntimeException, std::exception)
202 // Get list of types from the context base implementation...
203 uno::Sequence<uno::Type> aTypeList (2);
204 // ...and add the additional type for the component.
205 const uno::Type aComponentType =
206 cppu::UnoType<XAccessibleComponent>::get();
207 const uno::Type aExtendedComponentType =
208 cppu::UnoType<XAccessibleExtendedComponent>::get();
209 aTypeList[0] = aComponentType;
210 aTypeList[1] = aExtendedComponentType;
212 return aTypeList;
216 } // end of namespace accessibility
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */