1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20 #include <standard/vclxaccessibletextfield.hxx>
21 #include <vcl/toolkit/lstbox.hxx>
22
23 #include <com/sun/star/accessibility/AccessibleRole.hpp>
24 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
25
26 using namespace ::com::sun::star;
27 using namespace ::com::sun::star::uno;
28 using namespace ::com::sun::star::lang;
29 using namespace ::com::sun::star::beans;
30 using namespace ::com::sun::star::accessibility;
31
32
VCLXAccessibleTextField(VCLXWindow * pVCLWindow,const Reference<XAccessible> & _xParent)33 VCLXAccessibleTextField::VCLXAccessibleTextField (VCLXWindow* pVCLWindow, const Reference< XAccessible >& _xParent) :
34 VCLXAccessibleTextComponent (pVCLWindow),
35 m_xParent( _xParent )
36
37 {
38 }
39
40
implGetText()41 OUString VCLXAccessibleTextField::implGetText()
42 {
43 OUString aText;
44 VclPtr< ListBox > pListBox = GetAs< ListBox >();
45 if (pListBox && !pListBox->IsInDropDown())
46 aText = pListBox->GetSelectedEntry();
47
48 return aText;
49 }
50
IMPLEMENT_FORWARD_XINTERFACE2(VCLXAccessibleTextField,VCLXAccessibleTextComponent,VCLXAccessible_BASE)51 IMPLEMENT_FORWARD_XINTERFACE2(VCLXAccessibleTextField, VCLXAccessibleTextComponent, VCLXAccessible_BASE)
52 IMPLEMENT_FORWARD_XTYPEPROVIDER2(VCLXAccessibleTextField, VCLXAccessibleTextComponent, VCLXAccessible_BASE)
53
54
55 // XAccessible
56
57 Reference<XAccessibleContext> SAL_CALL
58 VCLXAccessibleTextField::getAccessibleContext()
59 {
60 return this;
61 }
62
63
64 // XAccessibleContext
65
getAccessibleChildCount()66 sal_Int32 SAL_CALL VCLXAccessibleTextField::getAccessibleChildCount()
67 {
68 return 0;
69 }
70
71
getAccessibleChild(sal_Int32)72 Reference<XAccessible> SAL_CALL VCLXAccessibleTextField::getAccessibleChild (sal_Int32)
73 {
74 throw IndexOutOfBoundsException();
75 }
76
77
getAccessibleRole()78 sal_Int16 SAL_CALL VCLXAccessibleTextField::getAccessibleRole()
79 {
80 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
81
82 return AccessibleRole::TEXT;
83 }
84
getAccessibleParent()85 Reference< XAccessible > SAL_CALL VCLXAccessibleTextField::getAccessibleParent( )
86 {
87 ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
88
89 return m_xParent;
90 }
91
92
93 // XServiceInfo
94
getImplementationName()95 OUString VCLXAccessibleTextField::getImplementationName()
96 {
97 return "com.sun.star.comp.toolkit.AccessibleTextField";
98 }
99
100
getSupportedServiceNames()101 Sequence< OUString > VCLXAccessibleTextField::getSupportedServiceNames()
102 {
103 return comphelper::concatSequences(VCLXAccessibleTextComponent::getSupportedServiceNames(),
104 Sequence<OUString>{"com.sun.star.accessibility.AccessibleTextField"});
105 }
106
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
108