1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_accessibility.hxx"
30 #include <accessibility/standard/vclxaccessibletextfield.hxx>
31 #include <vcl/lstbox.hxx>
32 #include <accessibility/helper/listboxhelper.hxx>
33 
34 #include <unotools/accessiblestatesethelper.hxx>
35 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
36 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
37 #include <com/sun/star/accessibility/AccessibleRole.hpp>
38 #include <vcl/svapp.hxx>
39 #include <vcl/combobox.hxx>
40 
41 using namespace ::com::sun::star;
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::lang;
44 using namespace ::com::sun::star::beans;
45 using namespace ::com::sun::star::accessibility;
46 
47 
48 
49 
50 VCLXAccessibleTextField::VCLXAccessibleTextField (VCLXWindow* pVCLWindow, const Reference< XAccessible >& _xParent) :
51 
52 	VCLXAccessibleTextComponent (pVCLWindow),
53 
54 	m_xParent( _xParent )
55 
56 {
57 }
58 
59 
60 
61 
62 VCLXAccessibleTextField::~VCLXAccessibleTextField (void)
63 {
64 }
65 
66 
67 
68 
69 ::rtl::OUString VCLXAccessibleTextField::implGetText (void)
70 {
71     ::rtl::OUString aText;
72     ListBox* pListBox = static_cast<ListBox*>(GetWindow());
73     if (pListBox!=NULL && !pListBox->IsInDropDown())
74 		aText = pListBox->GetSelectEntry();
75 
76     return aText;
77 }
78 
79 
80 
81 
82 IMPLEMENT_FORWARD_XINTERFACE2(VCLXAccessibleTextField, VCLXAccessibleTextComponent, VCLXAccessible_BASE)
83 IMPLEMENT_FORWARD_XTYPEPROVIDER2(VCLXAccessibleTextField, VCLXAccessibleTextComponent, VCLXAccessible_BASE)
84 
85 
86 //=====  XAccessible  =========================================================
87 
88 Reference<XAccessibleContext> SAL_CALL
89     VCLXAccessibleTextField::getAccessibleContext (void)
90     throw (RuntimeException)
91 {
92 	return this;
93 }
94 
95 
96 //=====  XAccessibleContext  ==================================================
97 
98 sal_Int32 SAL_CALL VCLXAccessibleTextField::getAccessibleChildCount (void)
99     throw (RuntimeException)
100 {
101     return 0;
102 }
103 
104 
105 
106 
107 Reference<XAccessible> SAL_CALL VCLXAccessibleTextField::getAccessibleChild (sal_Int32)
108     throw (IndexOutOfBoundsException, RuntimeException)
109 {
110     throw IndexOutOfBoundsException();
111 }
112 
113 
114 
115 
116 sal_Int16 SAL_CALL VCLXAccessibleTextField::getAccessibleRole (void)
117     throw (RuntimeException)
118 {
119 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
120 
121     return AccessibleRole::TEXT;
122 }
123 
124 Reference< XAccessible > SAL_CALL VCLXAccessibleTextField::getAccessibleParent(  )
125 	throw (RuntimeException)
126 {
127 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
128 
129 	return m_xParent;
130 }
131 
132 
133 
134 //===== XServiceInfo ==========================================================
135 
136 ::rtl::OUString VCLXAccessibleTextField::getImplementationName (void)
137     throw (RuntimeException)
138 {
139 	return ::rtl::OUString::createFromAscii ("com.sun.star.comp.toolkit.AccessibleTextField");
140 }
141 
142 
143 
144 
145 Sequence< ::rtl::OUString > VCLXAccessibleTextField::getSupportedServiceNames (void)
146     throw (RuntimeException)
147 {
148 	Sequence< ::rtl::OUString > aNames = VCLXAccessibleTextComponent::getSupportedServiceNames();
149 	sal_Int32 nLength = aNames.getLength();
150 	aNames.realloc( nLength + 1 );
151 	aNames[nLength] = ::rtl::OUString::createFromAscii(
152         "com.sun.star.accessibility.AccessibleTextField");
153 	return aNames;
154 }
155